Glossary

EXPLAIN (Query Plan)

EXPLAIN is a SQL command that shows how the database plans to execute a query: which tables it will read and in what order, which indexes it will use, how many rows it will scan. An indispensable tool for optimising slow queries.

Basic syntax

EXPLAIN SELECT * FROM orders
WHERE user_id = 42 AND status = 'paid';

-- more detail with actual execution analysis:
EXPLAIN ANALYZE SELECT ...;

What to look for

Step-by-step approach

Find a slow query → EXPLAIN → spot the ALL scan → add an index → check EXPLAIN again.