MySQL - 'Using index condition' 对比 'Using where; Using index'

MySQL - 'Using index condition' vs 'Using where; Using index'

我想知道 Using index conditionUsing where; Using index 之间的区别。 我认为这两种方法都使用索引来获取第一个结果记录集,并使用 WHERE 条件进行过滤。

Q1。有什么区别?

Q2。哪个更好?

谢谢。

Using index condition : where condition contains indexed and non-indexed column and optimizer will first resolve the indexed column and will look for the rows in the table对于另一个条件(索引下推)

在哪里使用;使用 index : 'Using index' 意味着不扫描整个 table。 'Using where' 可能仍会在非索引列上执行 table 扫描,但如果 where 条件中有任何索引列,它将首先使用,更像是使用索引条件

哪个更好? 'Using where; Using index' 会比 'Using index condition' 更好,如果查询的索引全部覆盖。

如果你看了这个link:https://dev.mysql.com/doc/refman/5.7/en/index-extensions.html

说明当'Column Extra'说'Using Index Condition'时,where条件中的所有列都在使用索引。如果有任何列超出索引,则 Column Extra 说 Using Where,Using Index(在这种情况下,Mysql 需要在数据行中查找以应用 where 子句)。比较好'Using Index Condition'.