【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的值),且没用到索引

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30221425/viewspace-2133122/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30221425/viewspace-2133122/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值