Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Reading traditional tabular EXPLAIN output is an essential skill for database engineers. The output table contains 12 columns, but four columns tell 90% of the optimization story: type, key, rows, and Extra.
type Column: The Access Method (Best to Worst)The type column describes how MySQL joins or scans table rows. Your primary objective in query optimization is moving from red/slow access types toward green/fast access types:
type Value | Rating | Meaning |
|---|---|---|
system / const | Best | Table has 1 row, or matched on Primary Key / Unique index equality. |
eq_ref | Best Join | One row read from this table for each combination from preceding table (PK/Unique join). |
ref | Great | Non-unique index lookup (multiple rows match the key). |
range | Good | Index range scan using BETWEEN, >, <, IN(). |
index | Slow | Full Index Scan (scans entire B+Tree from start to finish). |
ALL | Worst | Full Table Scan! Reads every data block on disk. Critical bottleneck! |
key and possible_keys Columnspossible_keys: The list of indexes MySQL could potentially choose to resolve the query.key: The actual index chosen by the cost-based optimizer.key is NULL, MySQL found no usable index and performed a Full Table Scan (type: ALL).rows and filtered Columnsrows: The estimated number of rows MySQL expects to inspect.filtered: The estimated percentage of inspected rows that will satisfy remaining table conditions (100% is ideal; 5% indicates 95% of inspected rows are discarded!).$$ ext{Rows Passed to Next Stage} = ext{rows} imes rac{ ext{filtered}}{100}$$
Extra Column: Flags of Honor & Red FlagsThe Extra column contains critical optimization flags:
Using index: Covering index! Data retrieved entirely from index B+Tree without touching table rows.Using index condition: Index Condition Pushdown is active.Using filesort: MySQL cannot use index ordering and must perform an extra sorting pass in memory/disk.Using temporary: MySQL must create an internal temporary table on disk or memory to hold intermediate results (frequent with messy GROUP BY and DISTINCT).Using where: Rows are filtered after being read from storage, rather than using an index range directly.Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Execution Plan Analysis with EXPLAIN & EXPLAIN ANALYZE | Identifying & Fixing Slow Queries & Filesort |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.