MySQL slow query log

Source: Internet
Author: User
Tags log log mysql slow query log

As the data volume continues to grow, performance is particularly important. Perhaps after optimization and good solutions, you cannot feel the existence of performance problems, but as the data volume continues to grow,

From millions to tens of millions to hundreds of millions, problems may arise. In order to better master the operational efficiency of the database, it is necessary to add slow log queries.

View log information:

The parameters are as follows:

-Slow_launch_time
If the thread creation time exceeds this number of seconds, the server adds the Slow_launch_threads status variable.

-Slow_query_log
Whether to record slow queries. Use the value of long_query_time to determine "Slow query ".

-Slow_query_log_file
Slow Log File Path

-Long_query_time
Slow log execution duration (seconds). logs are recorded only when the specified time is exceeded.

 

Log preparation: Modify the my. ini file to the following content:

# Enable slow log 1: Enable 0: Disable
Slow_query_log = 1

# Set the log duration in seconds)
Long_query_time = 2

 

Test slow log record information:

-Query the total number of records

-Collegets-slow.log log information (files are stored in the datadir directory by default)

C: \ Program Files \ MySQL Server 5.5 \ bin \ mysqld, Version: 5.5.23-log (MySQL Community Server (GPL). started:
TCP/IP Port: 3306, Named Pipe: (null)
Time id command argument
C: \ Program Files \ mysql server 5.5 \ bin \ mysqld, version: 5.5.23-log (MySQL Community Server (GPL). Started:
TCP/IP Port: 3306, named pipe: (null)
Time id command argument
# Time: 121205 16:09:31
# User @ host: Root [root] @ [192.168.17.105]
# Query_time: 2.171875 lock_time: 0.000000 rows_sent: 1 rows_examined: 2381725
Set timestamp = 1354694971;
Select count (*)
From usersession;

Related Article

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.