Reference · Cheat sheet

Write concern & read concern

Lesson 0008 distilled — w and j are orthogonal; together they set your durability/latency position. Built to print.

From lesson 0008Context: MongoDB current (7.0/8.0+)

The two axes — orthogonal

j — single-node durability: did this node's journal flush to disk? About surviving a process crash.

w — replication acknowledgment: how many nodes confirmed? About surviving a node failure.

Setting one says nothing about the other. Choose both deliberately.

Write concern w values

w: 0 — fire and forget.

w: 1 (default) — primary acked. Rollback risk if primary crashes before replication.

w: "majority" — majority of voting members acked. Any elected primary already has the write. No rollback.

Journal flag j

j: false (default) — ack without journal flush. Write is in memory. Lost if process crashes before next journal write (~100 ms).

j: true — wait for WAL flush before ack. Survives process crash. Small latency cost (sub-ms on SSD).

Combination matrix

w + jSurvivesUse for
w:1, j:falseNetwork errorsBulk loads, metrics
w:1, j:trueProcess crash on primaryMiddle ground
w:majority, j:falseNode failurePerf-sensitive, replicated
w:majority, j:trueCrash + node failureFinancial, orders, critical

Read concern

local (default) — most recent on the node; may include data that could roll back.

majority — only data acknowledged by a majority; cannot be rolled back. Pair with w: "majority".

linearizable — strongest: reflects all majority-acked writes before the read; primary-only, highest latency.

Postgres analog

MongoDBPostgres
w:1, j:falsesynchronous_commit = off
w:1, j:truesynchronous_commit = local
w:majority, j:truesynchronous_commit = on
readConcern: majorityread from primary + sync_commit on