Notestransactions🌱 seedling

Read Committed

Also: READ COMMITTED · RC · Read Committed Snapshot Isolation · RCSI

Read Committed guarantees no [[Dirty Read]]s and no dirty writes: you only read and overwrite committed data. Each statement sees the latest committed state, so two statements in one transaction can see different worlds.

Why it exists

It's the cheapest level that stops transactions from acting on each other's unfinished work, and it rarely blocks or aborts. That's why it's the default in Postgres, Oracle and SQL Server.

How it works

  • Writes: a writer takes a row lock and holds it until commit or abort; a second writer to the row waits.
  • Reads (MVCC engines): each statement gets a fresh snapshot of committed data, so readers never wait for writers. Postgres takes a new snapshot per statement.
  • Reads (locking engines): SQL Server's default takes short shared locks, so readers can block behind writers; READ_COMMITTED_SNAPSHOT switches to versioned reads (on by default in Azure SQL Database).
  • Postgres UPDATE re-check: if an UPDATE waits for a row lock and the row then changes, Postgres re-evaluates the WHERE clause against the new version before applying it.

Trade-offs

Gains Costs
few aborts, little blocking read skew between statements
cheap: per-statement snapshots Lost Updates, Write Skew and phantoms are on you

In practice

  • Safe single-statement patterns: UPDATE accounts SET balance = balance - 80 WHERE id = 1 AND balance >= 80 is race-free in Postgres Read Committed thanks to the re-check.
  • Unsafe: read in one statement, decide in code, write in another.

Pitfalls

  • Long reports and backups at Read Committed can mix data from before and after concurrent transactions; run them under Snapshot Isolation.

Recall

These cards are also in your review deck, scheduled with spaced repetition.