我正在调试 MySQL 5.1.61 数据库,我在 my.cnf
文件中将 long_query_time
设置为 10。慢速查询被记录到数据库表。
但是,它记录的查询只需要几分之一秒。
事实上,我的查询被记录的速度非常快,mysql 中的 query_time
字段为每个记录的查询显示“00:00:00”。即使当我让他们登录到文件时,他们显示的查询时间也在“Query_time: 0.004763”范围内
我知道我的配置文件正在被读取,因为我的所有其他更改都已生效。
根据我阅读的所有文档,long_query_time
应该是秒。我还需要做些什么才能使该设置生效吗?
最佳答案
那些查询有索引吗?如果不是,那么这可能就是它们被记录的原因。
Before MySQL 4.1, if you also use --log-long-format when logging slow queries, queries that are not using indexes are logged as well. Starting with MySQL 4.1, logging of queries not using indexes for row lookups is enabled using the --log-queries-not-using-indexes option instead. The --log-long-format is deprecated as of MySQL 4.1, when --log-short-format was introduced, which causes less information to be logged. (The long log format is the default setting since version 4.1.) (>>)
关于MySQL long_query_time 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10644253/