MySQL slow query log

wvanbergen edited this page Sep 4, 2010 · 3 revisions

As of version 1.5.0, request-log-analyzer supports parsing MySQL slow query logs. Use --format mysql to instruct r-l-a to parse a file as a slow query log.

Query duration in milliseconds

By default, MySQL reports the query and lock duration as whole seconds in the slow query log. To get a more detailed number for improved results, a patch is available that makes MySQL report the query duration as a floating point number in its log. Request-log-analyzer can parse these floating point numbers as well.

For more information about this patch, see the MySQL performance blog and the patch itself at MySQL forge.

Filtering SQL_NO_CACHE queries

If you encounter queries like SELECT !40032:SQL_NO_CACHE * FROM table; in your slow query log, you probably use the mysqldump tool to create backups of your database. You probably do not want to include these queries in your reports. You can filter them out using the --reject option:

request-log-analyzer mysql_slow_queries.log --reject query /SQL_NO_CACHE/

This will ignore all queries that include the SQL_NO_CACHE keyword.