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
1. Error details Once when manually performing a ...
Table of contents 1. Basic grammar 2. Filter by c...
1. Command Introduction The usermod (user modify)...
Preface Zabbix is one of the most mainstream op...
Table of contents 1. Resource files 2. Installati...
Table of contents Preface Type Inference Truth va...
When I was helping someone adjust the code today,...
Table of contents 1. for loop 2. Double for loop ...
Solution 1: Use conditional import in HTML docume...
The <label> tag defines a label (tag) for an...
First method Alibaba Cloud and Baidu Cloud server...
This article shares with you a book flipping effe...
JavaScript can do a lot of great things. This art...
This article shares the specific code of jQuery t...
This article uses examples to describe common ope...