The website access speed is too slow. We need to check all links that may drag down the website speed, here we will share some of the SQL statements in the database that have been executed with low efficiency to help us better optimize our website programs.
(1) set it in the MySQL configuration file. The specific location is my. ini/my. cnf. Enable MySQL slow query output: log_slow_queries and set its value to ON.
(2) set it on the MySQL client. Connect to the MySQL database server through a client and run the following SQL statement:
Set global log_slow_queries = ON; set global long_query_time = 3;
Here, you can record the SQL statements that take more than or equal to 3 seconds and output them to the log file. You may not know where this log file is stored? Run the following command on the MySQL client:
Show variables like 'slow _ query_log_file ';
The location of the log query file is displayed.
For the above two methods, I personally recommend the second one, because this method does not need to restart the MySQL service. Remember that the first method needs to restart the MySQL service!
Articles you may be interested in
- Mysql database cache function analysis, debugging, and performance summary
- MySQL large data volume quick insert method and statement Performance Optimization
- Summarize the causes and solutions for the slow MySQL Database Server
- Optimize paging SQL statements for large data volumes in MySQL
- Improve database performance secret SQL optimization skills
- Navicat for mysql remote connection to the mySql database prompt 10061,1045 error Solution
- Steps for synchronizing and backing up mysql Databases in windows
- Rational use of MySQL database indexes to make the database run efficiently