Getting a Plan Without Running the Query, and When EXPLAIN ANALYZE Is Unsafe
Plain EXPLAIN prints the plan the optimizer chose using only its estimates; it never executes the query. That matters when the statement would take an hour, or when it is an UPDATE or DELETE that you do not want to actually perform. EXPLAIN ANALYZE on a write really writes, so people wrap it in a transaction they roll back. Reach for plain EXPLAIN to answer 'what is it planning to do?' and for EXPLAIN ANALYZE to answer 'what did it really do?'.
Questions this Concept answers
Why do experienced engineers wrap `EXPLAIN ANALYZE` on an `UPDATE` in a transaction they roll back?
J
jeremy
Video
Reading a PostgreSQL Query Plan with EXPLAIN ANALYZE to Compare Estimated and Actual Rows
A relational database's cost-based query planner chooses an execution strategy that is invisible in the SQL text itself, and `EXPLAIN` / `EXPLAIN ANALYZE` exposes that choice as an execution plan: `E…