The Runtime Theory
DatabasesPlanned

How a Database Chooses a Query Plan

Video not available yet
#sql#query-planner#indexes

The lesson begins with a query for one user and draws the alternative sequential-scan and B-tree-index plans. It shows how table statistics inform row estimates, why an index scan can lose when many rows qualify, and how plan nodes feed rows into joins or aggregates.

The demonstration compares estimated and actual rows from EXPLAIN ANALYZE, including a note that the command executes the statement and adds instrumentation overhead. It closes with a practical debugging sequence: inspect the plan, compare estimates, verify indexes, and measure the whole request. Companion material: query-planning article, query trace, and PostgreSQL EXPLAIN.

Related articles

New lessons by email

Get new articles and notes on the systems behind everyday software.

One technical dispatch per week. No noise.

Not started

Sign in to save your learning progress.

Sign in to save