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.
- What does this mean in the 2nd row, is it not using the index listed
in the key column? -
How should I interpret what the contents of the
key column is about and how it is used?
enter code herea. Should I interpret this as
that index is used in the where stage of this query?
Best Answer
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. SeeEXPLAIN FORMAT=JSON SELECT ...
for specifically whichGROUP BY
and/orORDER BY
are creating a temp table and/or sorting.ref=const
probably means something like:INDEX(foo)
withWHERE foo=123
.key_len=8
usually refers to aBIGINT NOT NULL
.ref=Production1_
may be a truncation ofProduction1_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 ignoresGROUP BY
,ORDER BY
, andLIMIT
. Instead, it focuses on what index(es), if any, is used forWHERE
orON
.