// a hands-on teardown
HOW POSTGRES
WORKS
Most SQL tutorials treat Postgres as a black box. This one cracks it open — storage pages, B-trees, transaction visibility, the query planner — through interactive instruments you can probe yourself.
// the system, top to bottom
each stage a query passes through — and the lesson that opens it up.
- 01openStorage Layout
How a table really lives on disk: 8KB pages and tuples.
- 02openB-tree Indexes
Find one row among millions without reading them all.
- 03openQuery Planner
Seq scan vs index scan — how Postgres decides.
- 04openMVCC & Transactions
Row versions, snapshots, and how transactions stay isolated.
- 05openVACUUM & Bloat
Dead tuples, reclaiming space, autovacuum, and xid wraparound.
- 06openWAL & Durability
Write-ahead logging, crash recovery, checkpoints, replication.
- 07openThe Buffer Pool
shared_buffers, cache hits vs disk reads, and clock-sweep eviction.
- 08openLocks & Deadlocks
Row locks, lock waits, deadlock detection, and how to avoid them.
- 09openConnections & Pooling
Process-per-connection, max_connections, and why you need a pooler.
- 10openThe Executor
How a plan actually runs: a tree of nodes pulling rows one at a time.
- 11openDebugging Slow Queries
Find it, read the plan, fix it — the performance workflow.
- 12openPartitioning
Splitting a big table into partitions, and partition pruning.
- 13openReplication
Streaming WAL to standbys, sync vs async, lag, and failover.
- 14openRow-Level Security
Roles, GRANT, and policies that filter rows per tenant — Supabase's core.
- 15openOne Query, End to End
Trace a single query through every stage you've learned.