How do EXPLAIN and EXPLAIN ANALYZE differ, and how do you read an execution plan?
Short answer
EXPLAIN shows the plan the planner intends to run, with estimated cost and row counts, without executing it. EXPLAIN ANALYZE actually runs the statement and adds the actual time and row count of every node.
3 points to say:
EXPLAIN= estimates;EXPLAIN ANALYZE= real execution, so wrapUPDATE/DELETEin a transaction andROLLBACK.- Multiply
actual timebyloops; estimatedrowsfar from actual usually means bad statistics. - Add
BUFFERSto see whether data came from cache (hit) or disk.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.