Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Evaluating MySQL's slow query log with pt-query-digest from the Percona Toolkit, I need to group queries by transaction. As it seems, the easiest way to do this is to group by the Innodb_trx_id attribute.

However, my logs don't include this attribute. I tried with vanilla MySQL, MariaDB and Percona Server -- so I figure, you probably need to enable logging of this attribute. Any pointers on how to do this?

Thanks, Victor

share|improve this question
up vote 3 down vote accepted

The extended fields that Percona added are not available in stock MySQL.

The only other option is to add a comment to your SQL query in your app. The comments are added to the log, and pt-query-digest can parse fields out of comments with the --embedded-attributes option.

It's a bit tricky to discover the transaction id. You can query the transaction for your current thread:


But you find no row in that table until your transaction has created any locks. That is, a transaction that does nothing but SELECT will not show up in that table.

You could simply embed CONNECTION_ID() into your query comments, on the assumption that grouping by connection is as good as grouping by transaction.

share|improve this answer

MySQL Slow log is completely a separate entity from innodb_trx information which you get from Information_Schema innodb_trx table.

MySQl slow log logs all slow running queries specified while enabling it, it does not matter whether queries are within TRANSACTION or not slow log will record all slow running queries according to options specified in my.cnf file.

I suggest to understand these tables from I_S Innodb_trx, innodb_lock_waits and innodb_locks tables from I_S and analyze result of it.

share|improve this answer

As I found out, this seems to be a feature (exclusively?) available on Percona server. There, it can be enabled with "log_slow_verbosity=innodb" in my.cnf.

Does anyone know if there is a way to enable this information on a regular MySQL server?

share|improve this answer
If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. – ypercubeᵀᴹ Apr 10 '14 at 8:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.