What is the MySQL EXPLAIN command?

Why Interviewers Ask This

Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for MySQL / SQL development. It reveals whether you understand the building blocks that more complex concepts rely on.

Answer

EXPLAIN is a MySQL command that shows the execution plan for a SELECT, INSERT, UPDATE, or DELETE query — how MySQL intends to execute it, including which indexes it will use, estimated row counts, and join types. Usage: EXPLAIN SELECT * FROM users WHERE email = "alice@example.com";. Key columns in output: type — join type/access method (best to worst: system > const > eq_ref > ref > range > index > ALL); ALL means full table scan — almost always bad for large tables; possible_keys — indexes MySQL could potentially use; key — the index MySQL actually chose; rows — estimated number of rows MySQL expects to examine (lower is better); Extra — additional information: "Using index" (covering index, no table lookup), "Using filesort" (must sort in memory/disk — expensive), "Using temporary" (temporary table created — expensive), "Using where" (filtered after table read). EXPLAIN FORMAT=JSON provides more detail. EXPLAIN ANALYZE (MySQL 8.0+) actually executes the query and shows actual timing. Use EXPLAIN to diagnose slow queries and verify indexes are being used.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last MySQL / SQL project, I used this when...' immediately makes your answer more credible and memorable.