Chapter 16. Transactions and Locks

Unlike most other database systems, PostgreSQL does not use locks for concurrency control. Instead, it maintains data consistency by using multiversion model. When a database is queried, each transaction sees a snapshot of the data (a database version) as it was some time before, regardless of the current state of the underlying data. This protects the transaction from viewing inconsistent data that could be caused by (other) concurrent transaction updates on the same data rows, providing transaction isolation for each database session.

Multi-Version Concurrency Control (MVCC)

Multi-Version Concurrency Control (MVCC) is an advanced technique for improving database performance in a multi-user environment. The main difference between multiversion and lock models is that in MVCC locks acquired for querying (reading) data do not conflict with locks acquired for writing data. Therefore, reading never blocks writing and writing never blocks reading.