温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

MySQL慢查询日志不打印的示例分析

发布时间:2021-10-29 17:04:25 来源:亿速云 阅读:252 作者:小新 栏目:MySQL数据库

这篇文章给大家分享的是有关MySQL慢查询日志不打印的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

测试环境修改 long_query_time=0.2
当执行性以下查询时,慢查询日志没有生效
mysql> select sleep(5);

+----------+
| sleep(5) |
+----------+
|        0 |
+----------+
1 row in set (5.00 sec)


⑴于是检查参数
mysql> show variables like '%query%';
+------------------------------+------------------+
| Variable_name                | Value            |
+------------------------------+------------------+
| binlog_rows_query_log_events | OFF              |
| ft_query_expansion_limit     | 20               |
| have_query_cache             | YES              |
| long_query_time              | 1.000000         |
| query_alloc_block_size       | 8192             |
| query_cache_limit            | 0                |
| query_cache_min_res_unit     | 4096             |
| query_cache_size             | 0                |
| query_cache_type             | OFF              |
| query_cache_wlock_invalidate | OFF              |
| query_prealloc_size          | 8192             |
| slow_query_log               | ON               |
| slow_query_log_file          | /mlogs/slow1.log |
+------------------------------+------------------+

发现配置正常

⑵于是检查以下两个参数
min_examined_row_limit、long-queries-not-using-indexes
mysql> show variables like 'min_examined_ro%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| min_examined_row_limit | 10    |
+------------------------+-------+
1 row in set (0.00 sec)
mysql> show variables like 'log_queries_not_using_indexes';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| log_queries_not_using_indexes | OFF   |
+-------------------------------+-------+


然后将min_examined_row_limit置为0,慢查询会记录


两个参数:
 log_queries_not_using_indexes,为on时表示记录没用到索引的查询,即使没有超过long_query_time
 min_examined_row_limit,表示查询超过多少条就记录(当 min_examined_row_limit=on的时候)


原因:select sleep(5)语句查询没有记录(即<min_examined_row_limit的值),且没用到索引

</min_examined_row_limit的值),且没用到索引

感谢各位的阅读!关于“MySQL慢查询日志不打印的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI