当前位置:网站首页>Mysql. Slow Sql

Mysql. Slow Sql

2022-08-11 00:02:00 Wandering about the cat

Configure to enable logging

windows is my.ini file

linux and MacOs is my.cnf file

Enable slow query log

version 5.5 and above

slow_query_log=1

slow-query-log-file=/www/server/data/mysql-slow.log

long_query_time=1

Command ON

set global slow_query_log=1;

Invalid after restart, it is best to put it in the configuration file.

Turn on validation

SHOW VARIABLES LIKE '%slow_query_log%';

Slow query judgment time

SHOW VARIABLES LIKE 'long_query_time%';

Can be reset, this setting will be invalid after Mysql restarts.

set global long_query_time=3;

Check how many times the slow query occurs

show global status like '%Slow_queries%';

Test Validation

select sleep(11);

Log position

Slow Sql log:

Analyze slow query logs

Analyze the slow query log directly,

mysql uses the explain + sql statement to simulate the optimizer to perform the analysis.

oracle uses the explain plan for +sql statement to simulate the optimizer to perform the analysis.


原网站

版权声明
本文为[Wandering about the cat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/223/202208102346596168.html