MySQL慢查询日志记录快速查询 [英] MySQL slow query log logging fast queries
问题描述
我有一个问题,MySQL似乎在慢查询日志记录查询比指定的时间更快。我已配置MySQL记录以下内容:
I'm having an issue where MySQL seems to be logging queries in the slow query log that are faster than the time specified. I've configured MySQL to log the following:
Server version: 5.1.54-1ubuntu4-log
+---------------------+-------------------------------+
| Variable_name | Value |
+---------------------+-------------------------------+
| log_slow_queries | ON |
| long_query_time | 2.000000 |
| slow_query_log | ON |
| slow_query_log_file | /var/log/mysql/mysql-slow.log |
+---------------------+-------------------------------+
4 rows in set (0.00 sec)
但是,在我慢的查询日志中,我可以看到它是日志亚秒级查询:
However, in my slow query log I can see that it's logging sub-second queries:
# Time: 121116 17:09:00
# User@Host: user[user] @ ip-10-x-x-x.ec2.internal [x.x.x.x]
# Query_time: 0.007098 Lock_time: 0.000075 Rows_sent: 50 Rows_examined: 2693
我使用'SET GLOBAL ...'动态设置了上面的变量,但是在long_query_time设置为1.000000秒。
I've set the above variable dynamically using 'SET GLOBAL ...', but even before that the long_query_time was set to 1.000000 seconds.
任何想法为什么MySQL可以记录比指定的更快的查询。
Any idea why MySQL could be logging queries that are faster then what is specified?
推荐答案
根据文档,还有另一个选项可能导致查询记录在慢查询日志中:
According to the documentation, there's another option that could cause queries to get logged in the slow query log:
这篇关于MySQL慢查询日志记录快速查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!