From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christopher Browne <cbbrowne@acm.org>
Cc: pgsql-admin@postgresql.org
Subject: Re: autovacuum
Date: Sat, 04 Feb 2006 14:12:07 -0500
Message-ID: <20656.1139080327@sss.pgh.pa.us> (raw)
In-Reply-To: <m3k6cbmaxl.fsf@mobile.int.cbbrowne.com>
References: <6.2.1.2.2.20060204110331.03dc2eb0@81.215.12.210>
<m3k6cbmaxl.fsf@mobile.int.cbbrowne.com>
Christopher Browne <cbbrowne@acm.org> writes:
>> does autovacuum locks tables while vacuuming?
> Of course it does; any request to access a relation will issue one or
> more locks on the relation.
This is correct in general ...
> VACUUM issues an AccessShareLock request against each relation that is
> vacuumed, which is probably nearly the same lock request your
> applications will be requesting, save for the fact that they'll also
> be submitting some RowExclusiveLock requests for individual rows of
> relations.
... but wrong in detail. Actually VACUUM takes ShareUpdateExclusive
lock, which is a bit stronger than an ordinary reader's AccessShare
lock (it does not block ordinary reads or updates, but it does block
index creation as well as other attempts to VACUUM the table). Also,
RowExclusiveLock is a table-level lock. Data-modifying commands such
as UPDATE take RowExclusiveLock on the whole table as a means of letting
other sessions know that someone is changing the table. They also
take row-level locks on the specific rows they change.
This is all discussed here:
http://www.postgresql.org/docs/8.1/static/explicit-locking.html
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, cbbrowne@acm.org
Subject: Re: autovacuum
In-Reply-To: <20656.1139080327@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox