Caffeinated Coder
Book an appointment
Lesson 11 · Design

Query plans

SQL says what to find, never how. Before PostgreSQL runs a query, its planner builds the possible ways to answer it, estimates the cost of each from the table's statistics, and keeps the cheapest. Follow the planner through the PostgreSQL documentation's own example, SELECT * FROM tenk1 WHERE unique1 = 42, read the plan with EXPLAIN and EXPLAIN ANALYZE, and watch the best plan flip when the question asks for 7,000 rows instead of one.

12 min10 steps5 questionsIntermediate
Fig 11 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.