1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter12.Concurrency Control</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="sql.html" title="PartII.The SQL Language">
<link rel="prev" href="indexes-examine.html" title="11.9.Examining Index Usage">
<link rel="next" href="transaction-iso.html" title="12.2.Transaction Isolation">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en" id="mvcc">
<div class="titlepage"><div><div><h2 class="title">
<a name="mvcc"></a>Chapter12.Concurrency Control</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="sect1"><a href="mvcc.html#mvcc-intro">12.1. Introduction</a></span></dt>
<dt><span class="sect1"><a href="transaction-iso.html">12.2. Transaction Isolation</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="transaction-iso.html#xact-read-committed">12.2.1. Read Committed Isolation Level</a></span></dt>
<dt><span class="sect2"><a href="transaction-iso.html#xact-serializable">12.2.2. Serializable Isolation Level</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="explicit-locking.html">12.3. Explicit Locking</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="explicit-locking.html#locking-tables">12.3.1. Table-Level Locks</a></span></dt>
<dt><span class="sect2"><a href="explicit-locking.html#locking-rows">12.3.2. Row-Level Locks</a></span></dt>
<dt><span class="sect2"><a href="explicit-locking.html#locking-deadlocks">12.3.3. Deadlocks</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="applevel-consistency.html">12.4. Data Consistency Checks at the Application Level</a></span></dt>
<dt><span class="sect1"><a href="locking-indexes.html">12.5. Locking and Indexes</a></span></dt>
</dl>
</div>
<a name="id629789"></a><p> This chapter describes the behavior of the
<span class="productname">PostgreSQL</span> database system when two or
more sessions try to access the same data at the same time. The
goals in that situation are to allow efficient access for all
sessions while maintaining strict data integrity. Every developer
of database applications should be familiar with the topics covered
in this chapter.
</p>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="mvcc-intro"></a>12.1.Introduction</h2></div></div></div>
<a name="id629818"></a><p> Unlike traditional database systems which use locks for concurrency control,
<span class="productname">PostgreSQL</span>
maintains data consistency by using a multiversion model
(Multiversion Concurrency Control, <acronym class="acronym">MVCC</acronym>).
This means that while querying a database each transaction sees
a snapshot of data (a <em class="firstterm">database version</em>)
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 <em class="firstterm">transaction isolation</em>
for each database session.
</p>
<p> The main advantage to using the <acronym class="acronym">MVCC</acronym> model of
concurrency control rather than locking is that in
<acronym class="acronym">MVCC</acronym> locks acquired for querying (reading) data
do not conflict with locks acquired for writing data, and so
reading never blocks writing and writing never blocks reading.
</p>
<p> Table- and row-level locking facilities are also available in
<span class="productname">PostgreSQL</span> for applications that cannot
adapt easily to <acronym class="acronym">MVCC</acronym> behavior. However, proper
use of <acronym class="acronym">MVCC</acronym> will generally provide better
performance than locks.
</p>
</div>
</div></body>
</html>
|