technotes · topic
First-principles depth, taught by contrast with Postgres/InnoDB — the document model, WiredTiger storage, indexing, the aggregation pipeline, replica sets & sharding.
The document is the unit of storage, atomicity, and schema design — so embedding, single-document atomicity, and "design for your access pattern" all derive from one keystone fact.
doneThe storage engine up close — a B-tree, document-level concurrency, MVCC snapshots, the journal and checkpoints, and automatic space reuse (no VACUUM). The surprise: closer to InnoDB than to the Postgres heap.
doneB-tree indexes and the leftmost-prefix rule you know from SQL, plus the two Mongo-specific parts: ordering a compound index by Equality-Sort-Range, and indexing arrays (multikey).
doneCOLLSCAN vs IXSCAN, the examined-vs-returned tell, and the twist: Mongo races candidate plans and caches the winner by shape instead of costing them from statistics.
doneStages as a data pipeline — $match, $group, $sort, and $lookup (the join the document model avoids), plus why $match-first is predicate pushdown.
doneThe decision framework — one-to-few / one-to-many / one-to-squillions — and the anti-patterns (unbounded arrays, massive documents). Closes the loop from $lookup back to 0001.
doneOne primary, N secondaries, one oplog. The oplog is logical and idempotent — your MySQL binlog/Postgres WAL contrast, but built into the topology primitive. Automatic elections, failover window, read preference.
doneTwo orthogonal dials: w (replication acknowledgment) and j (journal flush). Their combinations set your durability/latency position — from fire-and-forget to majority + journaled. Read concern to match.
Horizontal scale: mongos router, config servers, shards (each a replica set). Shard key properties — cardinality, write distribution, query isolation. Targeted query vs scatter-gather. Range vs hash sharding. Anti-patterns.
doneThe escape hatch from single-document atomicity — snapshot isolation, write conflicts, the performance cost, and why schema design usually removes the need. Cross-arc synthesis quiz spanning all ten lessons.
doneexplain(),
or a Mongo-vs-relational contrast that feels off, and we'll dissect it together.