Database Internals
Pages, indexes, logs and transactions underneath SQL.
What happens inside a database: storage hardware, pages and rows, row and column stores, the buffer pool, B-trees, LSM trees and other indexes, query planning, join algorithms and the optimiser, write-ahead logging and crash recovery, transactions, isolation levels, locking, MVCC, replication and distributed SQL. Vendor-neutral: PostgreSQL, MySQL/InnoDB, SQLite, SQL Server, Oracle, RocksDB and the managed cloud databases. By the end you can read a query plan, choose indexes, reason about concurrency bugs and diagnose a slow database.
- 6
- chapters
- 21
- modules
- ~9h
- of learning
- 21
- live now
Take modules in any order. The route suggests one that builds up naturally.
has a live module in progress complete
Take a look inside
The big picture, before the details
One query's journey through a database engine, from SQL text to pages on disk, with the log and the copies that keep it safe. Watch the tour, or click any part.
A query arrives: SQL text over a connection: what you want, not how to get it (module 1).
A taste of module 15: two transactions collide at each isolation level. Find the lowest level that stops each glitch.
Each read a snapshot showing two doctors, each changed a different row, so no write conflict was detected. Run one after the other, the second would have stayed; together, nobody is on call. That's write skew.
The big picture
What a database does with your query, and the hardware it works with.
2 modules · 40 min
Storing data
How rows sit inside pages and files, and how memory caches them.
3 modules · 70 min
Indexes
Finding rows without reading everything.
4 modules · 100 min
Core
B-trees
The structure behind almost every index.
Applied
Using indexes well
When an index helps, and when it doesn't.
Core
LSM trees
Built for fast writes.
Core
Hash, inverted and vector indexes
Different questions need different indexes.
Running queries
Turning SQL into a plan, and a plan into rows.
3 modules · 75 min
Transactions and durability
Keeping data correct when things fail and users collide.
5 modules · 125 min
Core
Write-ahead logging and recovery
Surviving a crash mid-write.
Beginner
Transactions and ACID
All or nothing.
Core
Isolation levels and anomalies
What happens when users collide.
Core
Locks and deadlocks
Waiting your turn, and what happens when nobody can.
Core
MVCC
Readers that never wait for writers.
Beyond one machine
Copies, consensus and choosing an engine.
4 modules · 120 min
Core
Replication under the hood
Shipping the log to another server.
Deep dive
Distributed SQL and consensus
One database across many machines.
Applied
Database engines compared
PostgreSQL, MySQL, SQLite and the rest.
Applied
Capstone: the slow database
Diagnose a struggling database from the evidence.