]> begriffs open source - ai-pg/blob - full-docs/txt/mvcc-intro.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / mvcc-intro.txt
1
2 13.1. Introduction #
3
4    PostgreSQL provides a rich set of tools for developers to manage
5    concurrent access to data. Internally, data consistency is maintained
6    by using a multiversion model (Multiversion Concurrency Control, MVCC).
7    This means that each SQL statement sees a snapshot of data (a database
8    version) as it was some time ago, regardless of the current state of
9    the underlying data. This prevents statements from viewing inconsistent
10    data produced by concurrent transactions performing updates on the same
11    data rows, providing transaction isolation for each database session.
12    MVCC, by eschewing the locking methodologies of traditional database
13    systems, minimizes lock contention in order to allow for reasonable
14    performance in multiuser environments.
15
16    The main advantage of using the MVCC model of concurrency control
17    rather than locking is that in MVCC locks acquired for querying
18    (reading) data do not conflict with locks acquired for writing data,
19    and so reading never blocks writing and writing never blocks reading.
20    PostgreSQL maintains this guarantee even when providing the strictest
21    level of transaction isolation through the use of an innovative
22    Serializable Snapshot Isolation (SSI) level.
23
24    Table- and row-level locking facilities are also available in
25    PostgreSQL for applications which don't generally need full transaction
26    isolation and prefer to explicitly manage particular points of
27    conflict. However, proper use of MVCC will generally provide better
28    performance than locks. In addition, application-defined advisory locks
29    provide a mechanism for acquiring locks that are not tied to a single
30    transaction.