MySQL 5.5 Open Slow Log slow method (Log_slow_queries) _mysql

Source: Internet
Author: User

1.MySQL 5.5 command line inside

Copy Code code as follows:

Set global log_slow_queries = on; # Open Slow Log
Set [Session|global] long_query_time = 0.2 # setting time. Precise milliseconds
Set global log_queries_not_using_indexes = on; # set up a query without indexes

2. View the form of the store log
Mysql> Show variables like ' log_output ';

This file is meant to be stored in the form of a file.

If it is a table, it is stored in the system tables. Mysql.slow_log the table.

Use set global log_output= ' table '; Variable change

3. View the location of the slow log file (in file form)

4. Use the Mysqldumpslow command to view the slow log.

Detailed applicable mysqldumpslow-help query.

Parameter description:

-S, which means that the C, T, L, and R are sorted by record count, time, query time, number of records returned, AC, at, AL, AR, and the corresponding flashbacks.
-T is the meaning of top N, which returns the number of previous data.
-G, a regular matching pattern can be written behind, and case insensitive.

Mysqldumpslow-s c-t Host-slow.log

Lists the 10 SQL statements that return the largest recordset

Mysqldumpslow-s r-t Host-slow.log

Return the first 10 SQL statements containing the left connection in the 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.