Mysql enables slow query logs and queries-windows, mysql-windows
MySQL slow 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:
Show variables like '% quer % ';
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:
Add the following information to [mysqld:
[Mysqld]
Log-slow-queries = "C:/Program Files/MySQL Server 5.5/log/mysql-slow.log"
Long_query_time = 4
Log-queries-not-using-indexes
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 );
Log-queries-not-using-indexes: queries that are not indexed will also be recorded in the log.
Restart a MYSQL service after configuration.