Home >Database >Mysql Tutorial >Detailed introduction to mysql slow check log

Detailed introduction to mysql slow check log

黄舟
黄舟Original
2017-02-27 11:46:311172browse

In the performance optimization of MySQL, we often need to use slow check logs to analyze and optimize performance.

MySQL’s slow query log is a log record provided by MySQL. It is used to record statements whose response time exceeds the threshold in MySQL. Specifically, it refers to running SQL that 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 running statements for more than 10S. By default, the Mysql database does not start the slow query log. We need to manually set this parameter. Of course, if it is not needed for tuning, it is generally not recommended to start this parameter, because turning on the slow query log will bring more or less certain effects. performance impact. The slow query log supports writing log records to files and also supports writing log records to database tables.

## Check whether the slow check log is turned on:

##

show variables like 'slow_query_log';

Before turning it on, we need to confirm whether the index will not be used sql, recorded in the slow check log:

show variables like '%log%';

##Change it to the open state

 set global  log_queries_not_using_indexes=on;

Check how long the sql will be recorded in the slow check log

show variables like 'long_query_time';


Modify the value of long_query_time

Use set, for example:

 set long_query_time=0

Open Slow check log

 set global slow_query_log=on;

View the storage location of the slow check log

show variables like 'slow%';


Slow check log recording format

The above is the detailed introduction of the mysql slow check log. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!






#

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Get result set from PDONext article:Get result set from PDO