MySQL slow query log file path is generally:/var/lib/mysql/slowquery.log, the specific path can be queried through the MySQL configuration file (/etc/my.cnf), slow_query_log_file =/var/lib /mysql/slowquery.log
Log file data is generally a lot, if you look at a row by line, it will be time-consuming and laborious, for this problem, MySQL provides a command to summarize the slow query log data, and can be executed by the number of seconds, such as SQL order.
Mysqldumpslow-r-T Temp.log > Slow.txt
Mysqldumpslow command
/path/mysqldumpslow-s c-t 10/database/mysql/slow-log
This outputs 10 SQL statements with the highest number of records, where:
- -S, is the way to indicate the sort, C, T, L, R are in accordance with the number of records, time, query time, the number of records returned to sort, AC, at, AL, AR, indicating the corresponding flashbacks;
- -T, which is the meaning of top N, which is to return the data of the previous number of bars;
- -G, you can write a regular matching pattern, the case is not sensitive;
Like what
/path/mysqldumpslow-s r-t 10/database/mysql/slow-log
Get up to 10 queries that return recordsets.
/path/mysqldumpslow-s t-t 10-g "left join"/database/mysql/slow-log
Get the query that contains the left connection in the first 10 lines sorted by time.
MySQL parsing slow query