MYSQLSlow query Configuration
1. What is the use of slow queries?
It records all SQL statements that have been executed longer than long_query_time, and helps you find slow SQL statements to optimize these SQL statements.
2. How to enable slow query?
First, check whether the slow query status of the MYSQL server is enabled. Execute the following command:
We can see that the current log_slow_queries status is OFF, indicating that the slow query is not enabled currently.
It is very easy to enable slow query. The operations are as follows:
In Linux, find the mysql configuration file my. ini and add the slow query configuration statement below mysqld (Note: Be sure to add it below [mysqld)
Log-slow-queries: indicates the log storage directory of MYSQL slow query. This directory must have the write permission;
Windows need to write absolute path, such as: log-slow-queries = "C:/Program Files/MySQL Server 5.5/log/mysql-slow.log"
Long_query_time: Maximum execution time. (MSYQL records all SQL statements that have been executed for more than two times. The test time is used here. The time should not be too small. It is best to set the time to within 5-10 seconds, depending on your own standards );
Restart a MYSQL service after configuration.