21

I want to know difference between Using index condition and Using where; Using index. I think both method use index to fetch first result record set, and filter using WHERE condition.

Q1. What's the difference?

Q2. Which is better?

Thank you.

3
  • using index is when your where condition is covered by the indexed columns and it potentially does not need to scan the entire table. Using index condition is when the where condition contains indexed and non-indexed column and the optimizer will first resolve the indexed column and will look for the rows in the table for the other condition. The 2nd approach is called index push down. But ofcourse query with all covering index is better. Feb 27, 2015 at 7:29
  • @AbhikChakraborty Then 'Using where;' in 'Using where; Using index' meaning that where condition is covering on indexed columns and not scanning the table?
    – chris
    Feb 27, 2015 at 7:36
  • Yes using index meaning not doing the scan of entire table. Using where may still do the table scan on non-indexed column but it will use if there is any indexed column in the where condition first more like using index condition. Feb 27, 2015 at 7:38

2 Answers 2

16

Using index condition : where condition contains indexed and non-indexed column and the optimizer will first resolve the indexed column and will look for the rows in the table for the other condition (index push down)

Using where; Using index : 'Using index' meaning not doing the scan of entire table. 'Using where' may still do the table scan on non-indexed column but it will use if there is any indexed column in the where condition first more like using index condition

Which is better? 'Using where; Using index' would be better then 'Using index condition' if query has index all covering.

1
  • Does 'index condition pushdown' support update statement? From the source code, there is no conclude that update can use index condition pushdown.
    – egraldlo
    Feb 19, 2021 at 7:42
4

If you watch this link: https://dev.mysql.com/doc/refman/5.7/en/index-extensions.html

It explain that when 'Column Extra' says 'Using Index Condition', all columns in where condition are using index. If there are any columns out of index, then Column Extra say Using Where, Using Index (in this case, Mysql need look for in data row to apply where clause). It's better 'Using Index Condition'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.