1

I have a running script which is inserting data into a MySQL database.

I want to know how many rows are getting inserted per second and per minute. If the count of rows inserted per second or per minute goes beyond a certain count, I need to stop executing the script.

How can I monitor this?

George M
  • 13,959

2 Answers2

2

You should be able to derive that information from the output of

mysqladmin extended-status

Or

show status like 'Innodb_rows_inserted';

in MySQL, run every minute.

Or for individual databases or tables, you could use information from information_schema.TABLES:

select TABLE_NAME, TABLE_ROWS from information_schema.TABLES 
    where TABLE_SCHEMA = 'my-database';
  • That sounds about right. I also found out a command called watch, which lets me monitor the amount of records inserted per sec. – The Dark Knight Feb 21 '13 at 06:54
1

There are ways to do this via some count() on the db, but i think this will always be kind of ugly and just slow the execution of your script down. So the best way to do it is inside the script itself.

For example after every 1000 inserts you check the time since the last 1000 and then decide what to do.

replay
  • 8,553
  • 1
  • 27
  • 31