The Runtime Theory
Indexes and B-TreesPlanned

Video lesson: How a B-Tree Index Narrows a Database Search

Video not available yet
#indexes-and-b-trees#foundations

Lesson promise

By the end, the learner should be able to explain the core model for how a b-tree index narrows a database search, apply it to a concrete input, and identify when its usual shortcut or guarantee stops applying. This is a recording brief; publish it as a playable lesson after the narration and visual sequence have been produced and reviewed.

Narration draft

A database index is an auxiliary structure that helps find rows without scanning every table page. A B-tree keeps keys in sorted order across pages and uses separator keys to direct a search from the root toward a leaf. The index is valuable when its lookup cost is lower than the work it avoids.

For a query filtering by customer_id and ordering by created_at, a composite index beginning with customer_id may narrow to one customer’s key range and then return rows in order. If the query selects columns present in the index, some engines may avoid visiting table pages for each result.

Indexes consume storage and add work to inserts, deletes, and updates. A low-selectivity column may not justify an index by itself, and a query planner can prefer a sequential scan when many rows qualify. Composite index column order changes which predicates can use its leading range efficiently.

Visual sequence

  1. Put the input and assumptions on screen. Ask the learner to predict the next state before revealing it.
  2. Animate the representation and show the operation one transition at a time.
  3. Pause at the boundary case in the companion article and compare the result with the invariant.
  4. End with the exercise prompt: Given an index on (tenant_id, created_at), compare queries filtering by tenant_id alone and created_at alone. Explain what information the index ordering makes directly available.

Companion material

Use the article, trace, and interactive concept flow as the learner’s written and visual references. The video remains planned until an actual playable media URL and reviewed transcript are available.

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