What is the type column in MySQL EXPLAIN?
The type
column in the MySQL EXPLAIN output describes how a table will be accessed when running the query.
You're getting information on whether and how an index is used.
Some of these types expose technical implementation details and are, therefore, uninteresting to you.
In most cases, you can't do much to change the access method MySQL has chosen.
Any type
listed below as bad should be investigated closely to make the query faster.
And some of the good ones still have possible performance optimizations specific to their type.
Nevertheless, a high percentage of rows loaded with the index and really used (filtered
column) is the most important factor - especially as it is the deciding factor for the depends ones whether they are fast or slow.
Performance | Type | Description | |
---|---|---|---|
const
good
|
The table is replaced in the query by the row's columns | View | |
eq_ref
good
|
A primary/unique key is used to find rows in a join's target table | View | |
index_subquery
good
|
An IN(subquery) optimization when returning index values | View | |
range
good
|
An index is used to select rows based on a range condition | View | |
ref
good
|
Zero or more rows are loaded with an index | View | |
ref_or_null
good
|
A nullable condition is utilizing an index | View | |
unique_subquery
good
|
An IN(subquery) optimization when returning unique values | View | |
fulltext
depends
|
A full-text search is executed with the associated full-text index | View | |
index_merge
depends
|
Multiple indexes are combined to match the query's filters | View | |
ALL
bad
|
The full table is scanned without using an index | View | |
index
bad
|
An entire index was scanned due to the lack of a better one | View |