Chapter 9. Multiversion Concurrency Control

Table of Contents
9.1. Introduction
9.2. Transaction Isolation
9.3. Read Committed Isolation Level
9.4. Serializable Isolation Level
9.5. Data consistency checks at the application level
9.6. Locking and Tables
9.6.1. Table-level locks
9.6.2. Row-level locks
9.7. Locking and Indexes

9.1. Introduction

Unlike most other database systems which use locks for concurrency control, PostgreSQL maintains data consistency by using a multiversion model. This means that while querying a database each transaction sees a snapshot of data (a database version) as it was some time ago, 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.

The main difference between multiversion and lock models is that in MVCC locks acquired for querying (reading) data don't conflict with locks acquired for writing data and so reading never blocks writing and writing never blocks reading.