coo*_*fan 14 mysql performance mysql-5.5 slow-log
我注意到,在 Mysql 中,当启用log_queries_not_using_indexes
,slow_query_log
和 时long_query_time
,即使查询时间远小于long_query_time
.
似乎一旦log_queries_not_using_indexes
启用,无论“long_query_time”是什么,Mysql 都会记录所有不使用索引的查询。
有没有办法克服这个问题?我的意思是,有没有办法记录所有比 花费更长时间的查询long_query_time
,而不管它们是否使用索引?
小智 27
这是预期的行为。参考在线文档,但总而言之:
long_query_time
是记录查询执行时间的阈值。任何超过阈值的查询都会被记录下来,无论它们是否使用索引。
log_queries_not_using_indexes
告诉 MySQL 额外记录所有不使用索引的查询来限制扫描的行数。无论执行时间如何,都会发生这种情况的日志记录。
希望这有助于解释你所看到的。如果您的目标是仅捕获需要比特定阈值更长的查询,那么您可能只是想要long_query_time
而不是 log_queries_not_using_indexes
。
文档链接:http : //dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_log-queries-not-using-indexes
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_long_query_time