09, 13 chapters
how a query runs
everything.execution
how a query runs
parse, plan, execute. EXPLAIN, scans, joins, sorts, and the iterator that pulls one row at a time.
- 09.01relational algebraselection, projection, join and friends. the handful of operators every query compiles down to.
- 09.02the life of a queryparser, analyzer, rewriter, planner, executor. one query watched at every stage.
- 09.03the system catalogpg_class, pg_attribute, pg_type. the tables that describe your tables, and how names become numbers.
- 09.04reading EXPLAINa tree you read from the inside out. cost, rows, width, and what each number actually means.
- 09.05EXPLAIN ANALYZE and BUFFERSestimates next to actuals, loops, shared hit vs read, and the Index Searches line new in postgres 18.
- 09.06the executor and the iterator modelevery plan node answers one question: next row, please? press next() and watch one row climb.
- 09.07seq scans, index scans and bitmap scansthree ways to read a table, and the bitmap that turns random reads back into sequential ones.
- 09.08nested loop joinsfor each outer row, look for matches. dumb, and perfect when one side is tiny. plus Memoize.
- 09.09hash joinsbuild a hash table on the small side, probe it with the big one. and what happens when it doesn't fit.
- 09.10merge joinstwo sorted inputs, two cursors walking forward. why sorted order is a resource.
- 09.11sorting and work_memquicksort in memory, top-N heapsort for LIMIT, external merge on disk, and Incremental Sort.
- 09.12how GROUP BY runsHashAggregate vs GroupAggregate, and the hash table that spills to disk.
- 09.13parallel queryGather, workers and partial aggregates. why one query used four cores, and why it can't in this page.