MySQL parsing slow query

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.