日期:2014-05-16  浏览次数:20895 次

log-queries-not-using-indexes
本来我想记录慢查询:


【my.cnf】
SQL code
slow_query_log = /var/lib/mysql/slowquery.log  ##慢查询日志文件
     long_query_time = 3  ###慢查询时间
     log-queries-not-using-indexes

[Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-sl ave-statements have no effect if --log_slow_queries is not set

重启有这个警告 
意思是 log_slow_queries 这个没设置 索引的就没作用:
然后我设置log_slow_queries
重启;
 [Warning] '--log_slow_queries' is deprecated and will be removed in a future release. Please use ''--slow_query_log'/'--slow_query_log_file'' instead.

又说 log_slow_queries 过时了!!

现在该怎么正确的设置呢? 
我想的到超过3秒的记录下sql语句 或者 没有索引的查询也记录下来!

------解决方案--------------------
1 开慢查询不用重启

2 根本用不到log-queries-not-using-indexes这个参数


只需要set global slow_query_log=on;就可以了
------解决方案--------------------
--log_slow_queries' is deprecated 只是一个warning,它还是会生效的,当然,你最好是用它建议的
--slow_query_log
--slow_query_log_file
正确的用法是:
slow_query_log
slow_query_log_file=/var/lib/mysql/slowquery.log
log-queries-not-using-indexes

其中log-queries-not-using-indexes会记录所有没有用上索引全表扫描的语句,就算你的SQL没有超过long_query_time设置的时间。有些只有一二十条记录的表全表扫描并不是什么大事也会记录到你的慢查日志中,对慢查分析有一定的坏处,你需要斟酌加上这个参数。