Conceptual
Login

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?