PrefaceThe MySQL slow query log is a type of log record provided by MySQL. It is used to record statements in MySQL whose response time exceeds the threshold. Specifically, SQL statements whose running time exceeds the long_query_time value will be recorded in the slow query log. The default value of long_query_time is 10, which means that the statement runs for more than 10 seconds. By default, the MySQL database does not start the slow query log, and we need to manually set this parameter. Of course, if it is not required for tuning, it is generally not recommended to start this parameter, because turning on the slow query log will more or less bring certain performance impact. The slow query log supports writing log records to files or to database tables. The official document introduces the slow query log as follows (partial information, please refer to the official related link for details):
Slow query log related parametersMySQL slow query related parameter explanation:
The role of slow query logThe slow query log records the SQL statements that take longer than the specified time to execute. The slow query log can be used to locate and analyze performance bottlenecks. Check whether the slow query log function is enabled and the directory where the slow query log files are stored SHOW VARIABLES LIKE 'slow_query%' Enable slow query logging
In the MySQL configuration file /etc/my.cnf, set slow_query_log=ON long_query_time=1 Enable the slow query log to record SQL statements that take more than 1 second to query. The log will take effect after restarting MySQL. You can use the following sql to test the following SELECT SLEEP(2); Slow query log file Tcp port: 0 Unix socket: (null) Time Id Command Argument # Time: 210125 6:30:14 # User@Host: reptile[reptile] @ [192.168.10.254] Id: 1 # Query_time: 2.000380 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0 SET timestamp=1611556214; SELECT SLEEP(2);
SummarizeThis is the end of this article about the role and activation of MySQL slow query log. For more relevant MySQL slow query log content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: HTML Form Tag Tutorial (4):
>>: A brief discussion on the characteristics of CSS float
Nowadays, mobile devices are becoming more and mo...
Sometimes it is slow to download large network fi...
Storage rules for varchar In versions below 4.0, ...
1. Enable remote access to the docker server Log ...
When it comes to styling our web pages, we have t...
Enter ssh and enter the following command to rese...
This article example shares the specific code of ...
I was in a meeting when a colleague called to rep...
Preliminary Notes 1.Differences between Vue2.x an...
Attribute check-strictly The official document pr...
need: Usually, sites want to prevent videos and p...
As shown above, padding values are composite at...
Table of contents Passing parameters between pare...
1. Conclusion Syntax: limit offset, rows Conclusi...
1. Add a comment block at the beginning of the sty...