series
Reading Execution Plans
Three parts on turning a plan from a wall of text into a diagnosis — which EXPLAIN variant answers which question, the order to read a plan tree in, and the one comparison that localizes most problems.
3 parts · 11 min total
The examples use PostgreSQL 18, but the reading order and the estimate-versus-actual comparison transfer to any cost-based optimizer. Read the parts in order: each one assumes the previous.
In this series
- Part 1: EXPLAIN, ANALYZE, BUFFERS: Three Different QuestionsWhich variant you ran decides whether the numbers in front of you are the planner's estimate or a measurement, and whether the pages came from cache. · 4 min
- Part 2: Reading a Plan Tree: Start at the LeavesA plan is a tree printed upside down. Reading it in execution order instead of top to bottom turns a wall of text into a diagnosis. · 4 min
- Part 3: Estimated Versus Actual Rows: the First Number to CheckOne comparison localizes most plan problems. Find the deepest node where the planner's estimate and reality diverge, and stop reading upward. · 3 min