0

enter image description here

I've exported the results of an EXPLAIN run on a query. What I find confusing is that there's the key column listing out one of the indexes from the list of possible_keys(not shown in picture) however only the top row makes mention of Using index explicitely in the Extra column.

  1. What does this mean in the 2nd row, is it not using the index listed in the key column?
  2. How should I interpret what the contents of the key column is about and how it is used?
    enter code here

    a. Should I interpret this as that index is used in the where stage of this query?

asked Mar 11, 2020 at 18:13
1
  • It would be helpful to post the complete plan, along with the actual query and table definitions, because "using index" might mean different things in different contexts. Commented Mar 11, 2020 at 19:08

1 Answer 1

2

Using index means that the columns used for that table are all in the chosen index. This is called a "covering index".

Note the terminology confusion: the Key column tells you whether it is "using an index"; Using index says whether that index is "covering" in this usage.

Using index condition is something else; don't get confused.

Using temporary; Using filesort does not necessarily apply to the table in question. See EXPLAIN FORMAT=JSON SELECT ... for specifically which GROUP BY and/or ORDER BY are creating a temp table and/or sorting.

ref=const probably means something like: INDEX(foo) with WHERE foo=123. key_len=8 usually refers to a BIGINT NOT NULL.

ref=Production1_ may be a truncation of Production1_db.my_table.my_column

The second row does not say Using index because the index being used in the second table (FKB8...) is not "covering".

EXPLAIN mostly ignores GROUP BY, ORDER BY, and LIMIT. Instead, it focuses on what index(es), if any, is used for WHERE or ON.

answered Mar 12, 2020 at 0:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.