Mysql – Analyze general log

linuxMySQLmysql-5.6mysql-workbench

Motivation : understand the highest CPU\usage\long_query of historic queries running on production.

example :10 minute ago on server x graph showed high CPU usage.

I thougth for next steps :

  • Collecting the slow_query_log and move to another machine for storage and analyzing

  • Analyze production general log for better understanding .With which queries i should handle (active general_log for once a day for 20 minutes in production)

any better suggestions ?

Best Answer

I prefer the slowlog. But I also like to crank long_query_time down to 1.0 or less.

Use pt-query-digest to analyze the log. This can be done without copying it to another machine.

(Check the arguments to that tool to see if it can limit the output to a given time period.)