ACID

ACID is the set of guarantees a database transaction provides: Atomicity, Consistency, Isolation, Durability. ACID is the bedrock contract that makes relational databases trustworthy for financial, inventory, identity, and other workloads where partial or inconsistent state is unacceptable.

What each letter means

  • Atomicity. A transaction either completes entirely or has no effect. There is no halfway state visible to anyone else.
  • Consistency. A transaction takes the database from one valid state to another, respecting all declared constraints (foreign keys, uniqueness, check constraints).
  • Isolation. Concurrent transactions do not interfere with each other. Different isolation levels offer different tradeoffs between concurrency and anomalies.
  • Durability. Once a transaction commits, its effects survive crashes, power loss, and restarts.

Isolation levels

SQL defines four standard levels from weakest to strongest:

  • Read Uncommitted. Sees others' uncommitted changes (dirty reads).
  • Read Committed. Sees only committed data, but the same query can return different results in a transaction (non-repeatable reads).
  • Repeatable Read. Stable reads within a transaction; phantom rows may still appear.
  • Serializable. Behaves as if transactions ran one at a time.

Most databases default to Read Committed; some (PostgreSQL with serializable, CockroachDB) provide stronger guarantees via MVCC and serializable snapshot isolation.

🔗

Subscribe to Sahil's Playbook

Clear thinking on product, engineering, and building at scale. No noise. One email when there's something worth sharing.
[email protected]
Subscribe
Mastodon