【发布时间】:2016-11-25 04:50:56
【问题描述】:
我想检查我的服务器的查询是否正确使用了索引。所以我启用了log_queries_not_using_indexes,并运行了测试用例。
我发现下面的查询写在mysql.slow_log表上。
SELECT * FROM user_rel
WHERE (f = '5837be9dc34f747dbd7ba6c7' AND t = '5837be9dc34f747dbd7ba6ca')
OR (f = '5837be9dc34f747dbd7ba6ca' AND t = '5837be9dc34f747dbd7ba6c7')
LIMIT 2;
但我的EXPLAIN EXTENDED 结果似乎还可以。
# id, select_type, table, type, possible_keys, key, key_len, ref, rows, filtered, Extra
'1', 'SIMPLE', 'user_rel', 'range', 'f-t-UNIQUE,t_uid_idx', 'f-t-UNIQUE', '208', NULL, '2', '100.00', 'Using index condition'
请谁能解释一下为什么这个查询写成slow_log?
编辑 1
这里是关于慢查询日志记录的 mysql 选项。
log_output TABLE
log_queries_not_using_indexes ON
long_query_time 2.000000
min_examined_row_limit 0
slow_query_log ON
sql_log_off OFF
编辑 2
在我将min_examined_row_limit 更新为10 后,查询不再显示。但是为什么这会影响log_queries_not_using_indexes 结果呢?
【问题讨论】:
标签: mysql performance mysql-slow-query-log