Database Engineering · Internals layer

Database Internals

Why does the database behave this way internally? The practical layer teaches how to use databases correctly; this layer sits underneath it and derives every mechanism — pages, B+ trees, the buffer pool, WAL, MVCC, LSM trees, the query planner, replication — from the problem it solves. An interactive systems textbook, not a glossary.

Two layers, one domain

The learner should never feel these are separate products. Every practical lesson carries a “See how this works internally →” link; every internals lesson links back to where you meet it in practice.

Database Engineering
│
├── SQL · Data Modeling · Indexes · Transactions · Query Optimization
├── PostgreSQL · Redis · NoSQL · Scaling
│
└── Database Internals
    ├── Storage      ├── Pages         ├── Records
    ├── B+ Trees     ├── Buffer Mgmt   ├── WAL
    ├── MVCC         ├── Recovery      ├── LSM Trees
    ├── Query Engine └── Distributed Internals

Start here

Descend from a normal question

The defining experience: start where an engineer starts and go all the way down into the machinery.

Why is this query slow?
  1. Slow querypractical
  2. ↓Execution planpractical
  3. ↓Sequential scaninternals
  4. ↓Pagesinternals
  5. ↓Storage readsinternals
Why is the indexed query fast?
  1. Index scanpractical
  2. ↓B+ treeinternals
  3. ↓Internal pagesinternals
  4. ↓Leaf pageinternals
  5. ↓Buffer poolinternals
  6. ↓Recordinternals
What does COMMIT actually do?
  1. COMMITpractical
  2. ↓Transactioninternals
  3. ↓WALinternals
  4. ↓Durabilityinternals
  5. ↓Dirty pageinternals
  6. ↓Recoveryinternals
Why does DELETE not free space?
  1. DELETEpractical
  2. ↓MVCCinternals
  3. ↓Dead tuplesinternals
  4. ↓VACUUMinternals
  5. ↓Slotted pageinternals

How every internals lesson is taught

Never a definition first. The learner understands why a mechanism exists before memorising its name.

  1. Problem↓
  2. Naive solution↓
  3. Why it breaks↓
  4. Better idea↓
  5. Internal mechanism↓
  6. Trade-offs↓
  7. Real database
Example: the B+ tree
  1. ProblemScanning millions of rows is slow.
  2. Naive solutionMaintain searchable metadata: a sorted array of key → row.
  3. Why it breaksThe index is larger than memory; inserting into a sorted array shifts everything.
  4. Better ideaOrganise the index into storage-friendly pages, with a page of separators above.
  5. Internal mechanismA B+ tree: fanout ~200, height 3–4, linked leaves.
  6. Trade-offsEvery write maintains it; splits cost pages; low-selectivity lookups lose to a scan.
  7. Real databasePostgreSQL nbtree, InnoDB clustered index, SQLite B-tree.

Every lesson also offers four depths — Overview, Intermediate, Advanced, Internals — and labels every simulated number as an educational simulation, and every engine-specific section as PostgreSQL or InnoDB rather than “databases”.

Modules

0/42 lessons mastered · 42 interactives
Storage, Records & Pages0/4
Bytes, records, fixed-size pages, slotted layouts: how a table physically exists on disk, and why the page is the unit of everything.
explains: Fundamentals, PostgreSQL
Index Internals0/5
From "read every page" to a page-oriented B+ tree: derive the index, watch splits and merges, and see why fanout beats Big-O.
explains: Indexes
Buffer Management0/4
The page exists but reading it again is expensive: the buffer pool, hits and misses, dirty pages, pinning, LRU and Clock — then follow one read and one write through it.
explains: Query Plans, PostgreSQL
WAL & Recovery0/2
What survives if the machine dies after COMMIT: the write-ahead log, checkpoints, redo, undo and the restart sequence — with a crash button.
explains: Transactions
Transactions & MVCC Internals0/7
What a transaction is inside the engine: lock tables, waits-for graphs, version chains, snapshots, dead tuples and the same workload under three isolation levels.
explains: Transactions, Concurrency
LSM Trees0/6
The write-optimised alternative: memtables, SSTables, bloom filters, compaction, the three amplifications — and an honest B+ tree vs LSM comparison.
explains: NoSQL, Redis
Query Engine0/6
Parser, AST, planner, cost model, join algorithms and the executor: follow one SQL statement from text to result through the real in-browser engine.
explains: SQL, Query Plans
PostgreSQL & InnoDB Internals0/3
The general mechanisms as two real engines implement them: heap tuples, xmin/xmax, shared buffers and VACUUM versus clustered primary keys, redo and undo logs.
explains: PostgreSQL
Distributed Internals0/3
How changes actually propagate: the replication stream, partition functions, quorums, leader election — and a failure simulator you can break.
explains: Scaling, Distributed
Performance Internals0/2
Why is it slow, one layer down: page reads, buffer misses, scan choice, index maintenance, WAL, compaction — and one central simulator to turn the knobs.
explains: Query Plans, Scaling

Connected to the rest of Engineer Atlas

The same structure, seen from the database side.

Operating SystemsCaching → Buffer pool
Operating SystemsConcurrency → Transactions / MVCC
CompilersLexer, parser, AST → SQL front end
NetworkingLatency → Replication
Distributed SystemsConsensus → Distributed databases