Index

Module 01 · Database InternalsOne Database, to the Bolt

The plan, running

The Query Planner
The Query Planner · Open board

The planner’s side of a query: statistics in, one chosen plan out. This lesson starts where that board stops, at the moment the chosen plan begins to run and needs memory to do it.

Before you start. The Query Planner showed the planner: the part of Postgres that reads a summary of your data and bets on one way to answer a query. Database 07: The Query Layer built the other half by hand: a plan is a tree of small steps, and each step pulls rows from the one below it, one row at a time. This lesson is about what those steps do when the rows they must hold do not fit in the memory they were given.

Continue reading with a plan

The first three lessons of every track are free. This lesson is included with a plan, which unlocks every lesson, board, video, lab and paper for one price.

View plans →Already a member? Sign in

Lab

Your query has an index and Postgres refuses to use it. At what fraction of the table does reading all of it in order start to win?

Drag What fraction of the table the query actually matches upward one notch at a time, and watch The plan it picks.

Open The selectivity crossover →

Your sort spills to disk. Give it more memory and it stops. Why does nobody set work_mem to a gigabyte?

Click The default, then A big desk and The whole room, drag Sessions running it at once, and watch The whole box.

Open The work_mem dial →

Related paper

Review Database Internals →

Saved in this browser, and to your account when you sign in.