EXPLAIN Plan
Pronunciationiks-PLAYN plan
Definition
A step-by-step roadmap generated by a database engine showing how it will execute a query, including which indexes and joins it plans to use.
Where you hear it
Database optimization discussions, slow query troubleshooting, and performance tuning sessions.
Examples
Run
EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';to see if the query uses the email index.The execution plan showed a full table scan, which explained why the report query was so slow.
The plan shows the query scans the whole orders table, so an index on the date would help.
Common mistake
Assuming the database will always execute the query exactly as written, without realizing the engine might completely rearrange operations based on the plan.
Say it at work
- In a meeting or chat
Let's check the EXPLAIN plan for this query to see why it is doing a sequential scan instead of using our new index.
- In an email or ticket
I attached the EXPLAIN plan output to the ticket so we can review the join bottlenecks together.