Skip to content

Commit 8ac700a

Browse files
committed
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
1 parent cd959b1 commit 8ac700a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

doc/src/sgml/ref/reindex.sgml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,12 @@ REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { IN
275275
considerations are rather different. <command>REINDEX</command> locks out writes
276276
but not reads of the index's parent table. It also takes an
277277
<literal>ACCESS EXCLUSIVE</literal> lock on the specific index being processed,
278-
which will block reads that attempt to use that index. In contrast,
278+
which will block reads that attempt to use that index. In particular,
279+
the query planner tries to take an <literal>ACCESS SHARE</literal>
280+
lock on every index of the table, regardless of the query, and so
281+
<command>REINDEX</command> blocks virtually any queries except for some
282+
prepared queries whose plan has been cached and which don't use this very
283+
index. In contrast,
279284
<command>DROP INDEX</command> momentarily takes an
280285
<literal>ACCESS EXCLUSIVE</literal> lock on the parent table, blocking both
281286
writes and reads. The subsequent <command>CREATE INDEX</command> locks out

0 commit comments

Comments
 (0)