Mysql 5.5 Method for enabling slow log (log_slow_queries), logslowqueries

Source: Internet
Author: User

Mysql 5.5 Method for enabling slow log (log_slow_queries), logslowqueries

1. MySQL 5.5 command line

Copy codeThe Code is as follows:
Set global log_slow_queries = on; # enable slow logs
Set [session | global] long_query_time = 0.2 # set the time. exact millisecond
Set global log_queries_not_using_indexes = on; # set a query without an index.

2. view the log storage format
Mysql> show variables like 'Log _ output ';

This FILE is stored as a FILE.

If it is a TABLE, it is stored in the system TABLE. mysql. slow_log TABLE.

Use set global log_output = 'table'; variable to change

3. view the location where slow log files are stored (when files are stored)

4. Run the mysqldumpslow command to view slow logs.

You can use mysqldumpslow-help to query details.

Parameter description:

-S indicates the sorting method. c, t, l, and r are sorted by the number of records, time, query time, and number of returned records (from large to small ), ac, at, al, and ar indicate the corresponding flashback.
-T indicates the top n, that is, the number of previous data records returned.
-G, followed by a regular expression matching mode, which is case insensitive.

Mysqldumpslow-s c-t 10 host-slow.log

List up to 10 SQL statements that return a record set

Mysqldumpslow-s r-t 10 host-slow.log

Return the first 10 SQL statements containing the left join by Time

Mysqldumpslow-s t-t 10-g "left join" host-slow.log

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.