EXPLAIN vs EXPLAIN ANALYZE
February 5, 2026
I ran into this while debugging a slow SQL query.
When debugging a slow query, we can use these two:
explain: shows how the database plans to execute the query (estimated cost, rows, indexes used, join strategy, etc.)

explain analyze: actually runs the query and shows actual execution metrics (actual time taken, rows, loops), so it’s usually more accurate.

In general, explain analyze shouldn’t be run on data-modifying statements (create table, alter, update, insert, drop, delete, truncate) unless the intention is to modify data.
Also, if a query is extremely expensive, explain analyze can add unnecessary load because it’s a real run.
Best practice would. be to:
- Start with
explain - If the plan / cost estimates differ than what we expected then run
explain analyze.