Transactions for PostgreSQLs
Transactions group statements so they succeed or fail together, following ACID rules. PostgreSQL implements this with MVCC, multiversion concurrency control, where each transaction sees a snapshot and writers do not block readers. Isolation levels such as Read Committed and Serializable decide which anomalies are possible.
Stage: Concurrency and Indexing · Part of the PostgreSQL roadmap · Last reviewed 19 November 2026
What to learn in Transactions
- Wrap related statements in BEGIN and COMMIT, and roll back on error
- Explain how MVCC lets readers and writers run without blocking each other
- Compare Read Committed, Repeatable Read and Serializable isolation
- Lock rows with SELECT FOR UPDATE to avoid lost updates
- Explain why VACUUM is needed to remove dead row versions
Transactions interview questions
How does MVCC work in PostgreSQL?
Each row version carries transaction identifiers showing when it was created and removed. A query sees only versions visible to its snapshot, so updates create new versions instead of overwriting. Old versions become dead rows that VACUUM later reclaims.
What is the default isolation level in PostgreSQL and what can go wrong?
It is Read Committed, where each statement sees data committed before it began. Two statements in one transaction can see different results, called non-repeatable reads. Use Repeatable Read or Serializable if you need a stable view.
Where Transactions fits in the PostgreSQL roadmap
Transactions belongs to the Concurrency and Indexing stage (intermediate level). Correctness and speed.
Other units in this stage
Back to the full PostgreSQL roadmap