← PostgreSQL learning path
PostgreSQL · Module 7 of 10

Transactions and concurrency

Keep data correct when many users act at once.

📖 Key ideas

  1. BEGIN; ... COMMIT; groups statements; ROLLBACK undoes.
  2. ACID: Atomicity, Consistency, Isolation, Durability.
  3. MVCC lets readers and writers not block each other.
  4. Isolation levels: Read Committed (default), Repeatable Read, Serializable.
  5. SELECT ... FOR UPDATE locks rows you will change.
💡 Real-life example: MVCC is giving every reader their own snapshot photo while writers work on the real scene.
TransactionAll-or-nothing group of statements
MVCCMulti-version concurrency control
Isolation levelHow transactions see each other
FOR UPDATELocks selected rows