[Architecture] MySQL Log File-slow query log

Source: Internet
Author: User
Tags mysql slow query log
As the name suggests, the slow query log records a query with a long execution time. You can set a threshold value and record all SQL statements with a running time exceeding this value to the slow query log file.

As the name suggests, the slow query log records a query with a long execution time. You can set a threshold value and record all SQL statements with a running time exceeding this value to the slow query log file.

Homepage → Database Technology

Background:

Read News

[Architecture] MySQL Log File-slow query log

[Date:] Source: Linux community Author: linwaterbin [Font:]

As the name suggests, slow query logs record queries with a long execution time.

You can set a threshold to record all SQL statements whose running time exceeds this threshold to the slow query log file.

The threshold value can be set using the long_query_time parameter. The default value is 10 seconds.

It is required that the running time is exactly the same as long_query_time and will not be recorded.

In the source code, it is determined that the value is greater than long_query_time, not greater than or equal

Mysql> show variables like 'Log _ slow_queries ';
+ ------------------ + ------- +
| Variable_name | Value |
+ ------------------ + ------- +
| Log_slow_queries | ON |
+ ------------------ + ------- +
1 row in set (0.00 sec)

Mysql> show variables like 'long _ query_time ';
+ ----------------- + ----------- +
| Variable_name | Value |
+ ----------------- + ----------- +
| Long_query_time | 10.000000 |
+ ----------------- + ----------- +
1 row in set (0.00 sec)

Another parameter related to slow query logs is log_queries_not_using_indexes.

If the running SQL statement does not use an index, MySQL also records this statement to the slow query log file.

Mysql> show variables like 'Log _ queries_not_using_indexes ';
+ ------------------------------- + ------- +
| Variable_name | Value |
+ ------------------------------- + ------- +
| Log_queries_not_using_indexes | OFF |
+ ------------------------------- + ------- +
1 row in set (0.00 sec)

Here, I have not enabled it, but I need to remind you that if you modify this parameter online, no error is reported, but it does not take effect.

MySQL also provides the tool program mysqldumpslow for analyzing full query logs to help MySQL DBAs solve possible performance problems.

Example: Obtain the TOP-5 SQL statement:

[Mysql @ localhost bin] $./mysqldumpslow-s al-n 5/home/mysql/log/slow. log

Reading mysql slow query log from/home/mysql/log/slow. log
Count: 1 Time = 0.00 s (0 s) Lock = 0.00 s (0 s) Rows = 0.0 (0), 0users @ 0 hosts

  • 0
  • MySQL 5.6.10 cross-platform GTID replication practices

    [Architecture] MySQL Log File-Error Log

    Related information MySQL Log File MySQL slow query log

  • Management of binary log files in MySQL (AM)
  • [Architecture] MySQL Log File-error (13:18:38)
  • MySQL slow query log and Error Log by day round (09:44:17)
  • Image Information

    View All comments in this article (0)

    Comments

    Latest Information

    Popular this week

    Introduction to Linux community-advertisement service-website map-help Info-contact us
    The articles published on this site (LinuxIDC) do not mean that they agree with the statement or description. They only provide more information and do not constitute any suggestions.


    Copyright©2006-2011 Linux community All rights reserved Zhejiang ICP backup No. 06018118

    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.