ποΈ Database Internals
Core β Advanced
- Storage: pages, heap files, B+ trees vs LSM trees (write vs read amplification)
- WAL (write-ahead log), checkpoints, crash recovery
- Indexes: clustered vs secondary, composite (leftmost prefix), covering, partial, hash, GIN/GiST
- ACID in depth
- Isolation levels and anomalies: dirty read, non-repeatable read, phantom, lost update, write skew
- MVCC (Postgres tuples/xmin/xmax, vacuum) vs locking
- Query planning: cost-based optimizer, statistics, join algorithms (nested loop, hash, merge)
- Replication: sync/async, logical vs physical, replication lag
- Partitioning vs sharding; consistent hashing
- Connection pooling (HikariCP, PgBouncer) and why connections are expensive in Postgres
π§ͺ Labs (π’ warm-up β π‘ core β π΄ hard β β« boss)
- π’ Reproduce every isolation anomaly with two
psqlsessions - π‘
pageinspect: watch xmin/xmax/ctid change across UPDATE/DELETE - π΄ Build Your Own Database From Scratch in Go (build-your-own.org): B+tree + KV
- β« Tiny LSM in Go: memtable + WAL + SSTables + compaction; compare with bbolt
π§ Cognitive tasks
- Trade-off debate: B-tree vs LSM for Orbitβs append-heavy event history
- Predict β verify: index-only scan before and after VACUUM
π°οΈ Orbit integration
- The
run_eventstable design (append-only, partitioning plan) - Isolation level choice for lease acquisition
Go deeper
βοΈ PostgreSQL Internals Β· Redis Internals
Resources
- Database Internals (Alex Petrov)
- DDIA ch. 3 (Storage) and ch. 7 (Transactions) β
- CMU 15-445 (Andy Pavlo) lectures on YouTube β
- PostgreSQL 14 Internals (Egor Rogov, free PDF) Related: PostgreSQL