aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-04-11 09:49:13 +0900
committerMichael Paquier <michael@paquier.xyz>2022-04-11 09:49:13 +0900
commit8ac700acffc7b17d88414be47b8dff44fb1ea681 (patch)
tree1a3d8ac5a775424f79c7bd028bd06c97edb46df6
parentcd959b1b0662c9d57540b31961680c38037ffcd6 (diff)
downloadpostgresql-8ac700acffc7b17d88414be47b8dff44fb1ea681.tar.gz
postgresql-8ac700acffc7b17d88414be47b8dff44fb1ea681.zip
doc: Clarify behavior of query planner locking with REINDEX
The documentation of REINDEX has never mentioned that the query planner may take an ACCESS SHARE lock on the indexes depending on the query used. This adds also a note about prepared queries not impacted when they do not use the index(es) rebuilt. Author: Frédéric Yhuel Reviewed-by: Guillaume Lelarge, Justin Pryzby Discussion: https://postgr.es/m/65d08718-6f11-978a-4b5a-72b807d4c663@dalibo.com
-rw-r--r--doc/src/sgml/ref/reindex.sgml7
1 files changed, 6 insertions, 1 deletions
diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml
index e6b25ee670f..6a0eca8b9ac 100644
--- a/doc/src/sgml/ref/reindex.sgml
+++ b/doc/src/sgml/ref/reindex.sgml
@@ -275,7 +275,12 @@ REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { IN
considerations are rather different. <command>REINDEX</command> locks out writes
but not reads of the index's parent table. It also takes an
<literal>ACCESS EXCLUSIVE</literal> lock on the specific index being processed,
- which will block reads that attempt to use that index. In contrast,
+ which will block reads that attempt to use that index. In particular,
+ the query planner tries to take an <literal>ACCESS SHARE</literal>
+ lock on every index of the table, regardless of the query, and so
+ <command>REINDEX</command> blocks virtually any queries except for some
+ prepared queries whose plan has been cached and which don't use this very
+ index. In contrast,
<command>DROP INDEX</command> momentarily takes an
<literal>ACCESS EXCLUSIVE</literal> lock on the parent table, blocking both
writes and reads. The subsequent <command>CREATE INDEX</command> locks out