The Slow Query Log

The slow query log contains a record of all SQL commands that took longer than the time specified in the system variable long_query_time . This log can help identify problem queries and expose parts of your database or application that need tuning.

You can enable the slow query log with the --log-slow-queries=filename option. If no filename is provided, it defaults to hostname-slow.log. If no directory is given, the directory defaults to the data directory. The long_query_time variable can be set using the --set-variable long_query_time=time command-line option (in which time is specified in seconds).

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.