Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 07 · From Scratch · Database · with code: Go · about 20 min to read

Play it as a journeyTutor comes with a plan

Pages

Pages
Pages · Open board

From the small database this series builds, one of the six programs the From Scratch build makes from real ones. Follows Database 02: The Index, which turned a lookup into a single byte offset in the file.

Before you start. This series builds a small database of our own: a program that stores rows of data on disk and can find any one of them again on demand. So far it does two things. It writes every new row onto the end of a file, one after another, so nothing already there gets overwritten. And it looks up a row instantly, because a table kept in memory turns a key straight into the exact byte where that row starts, instead of reading the whole file to find it.

Lesson 48 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1962: a desk for 16,000 words and a drawer for 96,000
  • The fix: a drawer and a desk that behave like one thing
  • Your own file has been lying to you the same way
  • The fix in your own file: pages, and an address with two parts
  • Inside a page: two lists, growing to meet in the middle
  • Watching an address survive a shuffle
  • The crack a page cannot fix by itself

Terms it explains: page, slot, pager, buffer pool, slot directory, compaction, Change `PageSize` to 512.

Review From Scratch