4

I'm currently trying to figure out how to count the number of transactions/statements executed against a MySql database on a given interval.

Has anyone done this before?

Are there any mysql tables that track these metrics?

I know SQL Server tracks this sort of thing, but I haven't been able to find anything for mysql.

Thanks in advance!

dustyhoppe
  • 1,783
  • 16
  • 20

1 Answers1

4
mysql> SHOW ENGINE INNODB STATUS\G

...
------------
TRANSACTIONS
------------
Trx id counter 34824
...

The transaction id counter is incremented for every transaction involving an InnoDB table.

If your statement does not touch an InnoDB table, the number is not incremented. But you should be using InnoDB anyway.

In MySQL 5.6, there's also the INFORMATION_SCHEMA.INNODB_METRICS table, but it does not collect data by default -- you have to turn on each counter specifically (see documentation for details).

Community
  • 1
  • 1
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828