Learn VisualLearn DB Visual
JA

Read the Plan from Leaves Upward

EXPLAIN shows the plan the planner chose, along with its estimated cost and row count, without actually running the query. EXPLAIN ANALYZE runs the query and adds the actual time and row count alongside those estimates. Because it actually runs the statement, use a transaction and roll it back when applying it to an UPDATE or other mutating statement — later lessons cover transactions in detail. Comparing the two reveals whether the planner's statistics are stale — for example, a Seq Scan on orders estimated at 500 rows but actually returning 4,900 signals that the statistics need refreshing, which can lead the planner to pick a worse plan than it should.

Why is EXPLAIN ANALYZE risky for UPDATE?