Slow query log

Enabling and configuring the slow query log is explained in Chapter 12, Managing Logs, Managing the general query log and slow query log. Once the slow query log is enabled and queries are collected, you can run pt-query-digest by passing the slow query log.

Suppose the slow query file is at /var/lib/mysql/mysql-slow.log:

shell> sudo pt-query-digest /var/lib/mysql/ubuntu-slow.log > query_digest

The digest report contains queries ranked by the number of query executions multiplied by the query time. Query details such as the query checksum (a unique value for each type of query), average time, percentage time, and number of executions are shown for all queries in the summary. You can drill down to the specific query by searching ...

Get MySQL 8 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.