EXPLAIN shows the planner’s estimated execution plan; EXPLAIN ANALYZE actually runs the query and reports real timings and row counts per step.
EXPLAIN alone is cheap (no execution) but can be wrong when statistics are stale, which is exactly when you need real numbers most.
EXPLAIN ANALYZE executes the query, so:
- It’s safe for
SELECTs but can be dangerous onUPDATE/DELETE— it actually runs them. - Compare
rows(estimated) againstactual rowsto spot bad cardinality estimates. - A big gap between estimated and actual rows on a step is usually the first place to look when a query is slow.
