Mysql:为什么这些查询被记录下来'因为'没有使用索引'当他们

时间:2015-01-29 21:10:18

标签: mysql logging indexing

所以,我试图找到不正确使用索引的联接,但是日志中充满了似乎有索引的查询。

我打开slow_query_log并打开log_queries_not_using_indexes并将long_query_time设置为10秒。

日志开始充斥着像这样的行......

Query_time: 0.320889  Lock_time: 0.000030 Rows_sent: 0  Rows_examined: 338336
SET timestamp=1422564398;
select * from fversions where author=155669 order by entryID desc limit 40;

查询时间低于10秒,根据此解释,它似乎使用主键作为索引。

为什么要记录此查询?我无法查看问题查询以向其添加索引。太吵了。

提前致谢!

PS。对此的答案似乎并不适用,因为我有一个' where'。 MySQL why logged as slow query/log-queries-not-using-indexes when have indexes?

mysql> explain select * from fversions where author=155669 order by entryID desc limit 40;
+----+-------------+-----------+-------+---------------+---------+---------+------+------+-------------+
| id | select_type | table     | type  | possible_keys | key     | key_len | ref  | rows | Extra       |
+----+-------------+-----------+-------+---------------+---------+---------+------+------
|  1 | SIMPLE      | fversions | index | NULL          | PRIMARY | 8       | NULL |   40 | Using where |
+----+-------------+-----------+-------+---------------+---------+---------+----
  

块引用

- + ------     1行(0.00秒)

mysql> show variables like 'slow_query_log';
+----------------+-------+
| Variable_name  | Value |
+----------------+-------+
| slow_query_log | ON    |

mysql> show variables like 'long_query_time';
+-----------------+-----------+
| Variable_name   | Value     |
+-----------------+-----------+
| long_query_time | 10.000000 |

mysql> show variables like 'log_queries_not_using_indexes';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| log_queries_not_using_indexes | ON    |

0 个答案:

没有答案