MySQL慢查询日志记录快速查询

时间:2022-12-06 23:36:55

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:

我有一个问题,MySQL似乎在慢速查询日志中记录的查询比指定的时间更快。我已经配置MySQL来记录以下内容:

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

I've set the above variable dynamically using 'SET GLOBAL ...', but even before that the long_query_time was set to 1.000000 seconds.

我使用'SET GLOBAL ...'动态设置了上面的变量,但在此之前,long_query_time设置为1.000000秒。

Any idea why MySQL could be logging queries that are faster then what is specified?

知道为什么MySQL可以记录比指定的更快的查询吗?

1 个解决方案

#1


23  

According to the documentation, there's another option that could cause queries to get logged in the slow query log:

根据文档,还有另一个选项可能导致查询记录在慢查询日志中:

log_queries_not_using_indexes

log_queries_not_using_indexes

#1


23  

According to the documentation, there's another option that could cause queries to get logged in the slow query log:

根据文档,还有另一个选项可能导致查询记录在慢查询日志中:

log_queries_not_using_indexes

log_queries_not_using_indexes