Reading EXPLAIN Cost Estimates and Row Counts
Learn how to interpret the cost numbers, estimated rows, and width values that EXPLAIN attaches to each plan node, and how to spot when the planner's estimates are wrong.
What the Cost Numbers Mean
Every node in an EXPLAIN plan shows a cost=startup..total pair. These are arbitrary planner units, not milliseconds. The planner uses them only to compare alternative plans and pick the cheapest one.
Startup vs Total Cost
The two numbers tell different stories:
- Startup cost: work before the first row is returned (e.g. building a hash table)
- Total cost: work to return all rows
A node that must sort or aggregate everything has a high startup cost.
All lessons in this course
- Introduction to EXPLAIN and ANALYZE
- Interpreting Plan Nodes
- Identifying Performance Bottlenecks
- Reading EXPLAIN Cost Estimates and Row Counts