MySql5.5 SQL optimization slow query log storage

Source: Internet
Author: User

first, MySQL's slow query log opening and storage

1, check whether the SQL records that do not use the index to the slow query log, view the log_queries_not_using_indexes variable;

 like "Log_queries_%"

Results:

If the value of the query is off, it indicates that there is no record, set to on to open the record;

Set = on;

2, check the query time Long_query_time, that is, the query time is greater than this value (in seconds), then log SQL to the slow query log;

 like "Long_query_time"

Results:

set global long_query_time=0.1; /* Set to 100MS */

reopen a Query window , the value of query Long_query_time is modified to 0.1;

Results:

3, check whether to open the slow query log, variable Slow_query_log;

 like "Slow_query_log"

If the value is off, it is not turned on; it should be set to on to open;

Set = on;

4. View the location of the slow query log and view the Slow_query_log_file variable

 like "Slow%"

Results:

5, slow query log storage format:

6, Slow query log analysis tool

(1) Mysqldumpslow use, check the Help

(2) View the top 3 of the path in the slow query log of/home/mysql/data/mysql-slow.log;

Results:

MySql5.5 SQL optimization slow query log storage

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.