A course grounded in your services

PostgreSQL, from newcomer to interview-ready

From the relational model to MVCC, indexes & the planner — anchored to your code.

You use Postgres through pgx every day, but you're newer to SQL and the internals — so this course ramps from the relational model and basic SQL up to the advanced areas that win interviews: how data is stored, MVCC, indexes, and the query planner. Then it ties it all back to how your Go services actually talk to the database. Six parts, built one at a time. Lessons are short — one win each. Read them in order.

How to use this Do one lesson, take its quiz from memory (no peeking), then skim the matching row of the cheat sheet. Come back a day later and re-take it — spacing beats cramming. Your fourth course; you know the rhythm. Stuck? Ask me — I'm your teacher, not just the author.

Part 1 — Relational & SQL foundations available now

Start here: the model everything rests on, and the SQL you'll read in every repo.

1 · Postgres & the relational model

Tables, rows, relations — and why an RDBMS, told through your emails table.

ready

2 · Data types, schema & constraints

Columns, types, NULL, primary/foreign keys, and constraints that protect data.

ready

3 · Querying: SELECT, JOIN, aggregate

Reading data — WHERE, joins, GROUP BY — the everyday SQL.

ready

4 · Writing data & UPSERT

INSERT/UPDATE/DELETE, ON CONFLICT upserts, and a first look at transactions.

ready

Part 2 — Internals & data structures available now

Under the surface — how Postgres stores, versions, and protects your data.

5 · Storage: pages & tuples

A table is a file of 8 KB pages; a tuple is a row version.

ready

6 · MVCC

The big one — new versions, snapshots, readers don't block writers.

ready

7 · TOAST

How big JSONB/arrays live out-of-line — and why SELECT * costs I/O.

ready

8 · WAL

Durability & crash recovery — and the log that feeds your Kafka CDC.

ready

9 · VACUUM & bloat

Why MVCC needs cleanup; autovacuum, HOT, and the "still huge" gotcha.

ready

Part 3 — Indexes available now

The side structures that skip the sequential scan — built on Part 2's storage model.

10 · Why indexes exist: the B-tree

Avoiding the seq scan; the balanced tree you'll use 90% of the time.

ready

11 · Beyond B-tree

GIN, GiST, BRIN, Hash — your trigram/array search is GIN.

ready

12 · Advanced indexing

Composite (leading-prefix), partial, covering, expression.

ready

13 · Index trade-offs

Write cost, when not to index, and why a present index isn't used.

ready

Part 4 — Query performance available now

Where indexes become visible — see a plan get chosen, and fix it.

14 · The planner & statistics

Cost-based planning from statistics — and why stale stats make queries slow.

ready

15 · Reading EXPLAIN / ANALYZE

The single most useful skill — read the tree, spot estimate-vs-actual gaps.

ready

16 · Scans & joins

Seq/Index/Bitmap; Nested-Loop/Hash/Merge — and when each is chosen.

ready

17 · Tuning slow queries

A repeatable method — the span → /query-db → EXPLAIN → fix loop.

ready

Part 5 — Transactions & concurrency available now

Correctness under load — all resting on the MVCC from Part 2.

18 · ACID & isolation levels

The four guarantees; Read Committed / Repeatable Read / Serializable.

ready

19 · Locks & deadlocks

Reads don't lock, writes do; FOR UPDATE; how deadlocks form & resolve.

ready

20 · Concurrency anomalies & SSI

Lost update, write skew — and exactly which level/technique stops each.

ready

Part 6 — PostgreSQL in Go (this repo) available now

Everything you learned, back in Go — pgx, the DB layer, migrations, and RLS.

21 · pgx & the connection pool

The driver and pooling your services use — and where per-request security is injected.

ready

22 · The database layer

Ext/Tx, entities, ExecInTx — the Go course made concrete.

ready

23 · Migrations & schema lifecycle

golang-migrate, forward-only, CONCURRENTLY — how schema changes ship.

ready

24 · RLS & multi-tenancy

resource_path from JWT to row — where all four courses meet.

ready

Reference shelf

Cheat sheet

Dense revision sheet + interview one-liners.

Glossary

The canonical vocabulary, opinionated.

Repo Postgres map

Ground truth: our pgx layer, migrations, indexes, RLS.

Resources

Official docs, Use The Index Luke, Rogov internals, pgx.

All 24 lessons are built — the full course, from the relational model to RLS multi-tenancy. The last mile is retrieval, not reading: ask me to run a mixed mock interview across all four courses (Postgres, gRPC, Go, Kafka), and where you're solid I'll record it so we both know it's locked in.