Detailed introduction to mysql slow check log

黄舟
Release: 2017-02-27 11:46:31
Original
1056 people have browsed it

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';
Copy after login

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%';
Copy after login

##Change it to the open state

set global log_queries_not_using_indexes=on;
Copy after login

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

show variables like 'long_query_time';
Copy after login


Modify the value of long_query_time

Use set, for example:

set long_query_time=0
Copy after login

Open Slow check log

set global slow_query_log=on;
Copy after login

View the storage location of the slow check log

show variables like 'slow%';
Copy after login


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 (m.sbmmt.com)!






#

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!