Mysql optimization -- slow query log

Mysql series article home page 

===============

The slow query log function is not enabled by default. If it is not required for tuning, it is generally not recommended to enable it.

Check whether the slow query log is enabled:

SHOW VARIABLES LIKE '%slow_query_log%'

On:

SET GLOBAL slow_query_log = 1;

If this function is enabled, what kind of Sql will be recorded in the slow query log?

This is controlled by the parameter long_query_time, the default value is 10 seconds, the viewing command is as follows:

SHOW VARIABLES LIKE '%long_query_time%';

Note: It will be recorded only if it is strictly greater than long_query_time (equal to will not be recorded)

Command to set long_query_time:

SET long_query_time = 3;

A case: rest (sleep) for 4 seconds

SELECT SLEEP(4);

Check which file the slow query log is written to:

SHOW VARIABLES LIKE '%slow_query_log%'

The content and description of the file are as follows:

Check how many slow query records there are in the current system:

SHOW GLOBAL STATUS LIKE '%Slow_queries%'

 

Log analysis tool: mysqldumpslow

Why can't I use it? ?

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324815502&siteId=291194637