Conceptual
Login

Estimated Rows vs Actual Rows, and Why loops Multiplies Everything You See

Each line of EXPLAIN ANALYZE carries both the planner's guess (rows=) and reality (actual rows=), plus loops=, the number of times that step ran. The numbers printed for a step are per loop averages, so a step showing 3 rows and 0.02 ms with loops=50000 really produced 150,000 rows and spent a full second. Comparing estimate to actual finds the planner's mistake; multiplying by loops finds the real cost. Missing the multiplication is the single most common mistake people make when reading a plan.

Questions this Concept answers

  • Why do the `actual time` and `actual rows` figures printed on a node with `loops=50000` mislead someone who reads them as totals?