22

I want to know the difference between ‘Using index condition’ and ‘Using where, Using index.’ I think both methods use an index to fetch the first result record set and filter the data using the WHERE condition.

Q1. What’s the difference?

Q2. Which one is better?

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. Commented 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? Commented 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. Commented Feb 27, 2015 at 7:38

3 Answers 3

17

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Does 'index condition pushdown' support update statement? From the source code, there is no conclude that update can use index condition pushdown.
2

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'.

Comments

0

From my perspective, they are not comparable because they are different optimize methods for different scenarios.

  1. "Using where; Using index" indicates that all the data you need are in the index.
  2. "Using index condition" indicates that MySQL still needs to look for other information through the table.

However, on some levels, "Using where; Using index" will be better because looking information through the table is time-consuming.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.