From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: zyake.mk4@gmail.com
Subject: Required locks for ANALYZE
Date: Tue, 20 Aug 2019 07:47:12 +0000
Message-ID: <156628723253.1296.7377373462603881976@wrigleys.postgresql.org> (raw)
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/9.5/sql-select.html
Description:
The below document says that the ANALYZE statement requires a read lock.
https://www.postgresql.org/docs/current/sql-analyze.html
-----
ANALYZE requires only a read lock on the target table, so it can run in
parallel with other activity on the table.
-----
But it is too vague as there is no such table level lock. In addition, the
document explains the SHARE UPDATE EXCLUSIVE table lock obtained by
ANALYZE.
https://www.postgresql.org/docs/current/explicit-locking.html
-----
SHARE UPDATE EXCLUSIVE
Conflicts with the SHARE UPDATE EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE,
EXCLUSIVE, and ACCESS EXCLUSIVE lock modes. This mode protects a table
against concurrent schema changes and VACUUM runs.
Acquired by VACUUM (without FULL), ANALYZE, CREATE INDEX CONCURRENTLY,
CREATE STATISTICS and ALTER TABLE VALIDATE and other ALTER TABLE variants
(for full details see ALTER TABLE).
-----
Therefore, in my opinion, the below paragraph should be amended as below.
* Before
-----
ANALYZE requires only a read lock on the target table, so it can run in
parallel with other activity on the table.
-----
* After
-----
ANALYZE requires only a SHARE UPDATE EXCLUSIVE lock on the target table, so
it can run in parallel with queries requiring ACCESS SHARE/ROW SHARE/ROW
EXCLUSIVE locks such as SELECT, UPDATE, DELETE, INSERT on the table.
-----
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-docs@postgresql.org
Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, zyake.mk4@gmail.com
Subject: Re: Required locks for ANALYZE
In-Reply-To: <156628723253.1296.7377373462603881976@wrigleys.postgresql.org>
* 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