11

我遇到了一个问题,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)

但是,在我的慢查询日志中,我可以看到它正在记录亚秒级查询:

# 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 秒。

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

4

1 回答 1

30

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

log_queries_not_using_indexes

于 2012-11-16T17:24:31.973 回答