Commit aa783575 authored by Alvaro Herrera's avatar Alvaro Herrera

doc: Explain 'invalid' index state for CREATE INDEX CONCURRENTLY

It wasn't previously mentioned that the index is created as invalid,
which is confusing to new users.

Backpatch to 14 (only because of a conflict in 13).

Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reported-by: default avatarLauren Fliksteen <dancernerd32@gmail.com>
Reviewed-by: default avatarRajakavitha Kodhandapani <krajakavitha@gmail.com>
Discussion: https://postgr.es/m/165290238488.670.7500177735573254738@wrigleys.postgresql.org
parent 3a8d83ca
...@@ -606,7 +606,8 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class= ...@@ -606,7 +606,8 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
</para> </para>
<para> <para>
In a concurrent index build, the index is actually entered into In a concurrent index build, the index is actually entered as an
<quote>invalid</quote> index into
the system catalogs in one transaction, then two table scans occur in the system catalogs in one transaction, then two table scans occur in
two more transactions. Before each table scan, the index build must two more transactions. Before each table scan, the index build must
wait for existing transactions that have modified the table to terminate. wait for existing transactions that have modified the table to terminate.
...@@ -615,7 +616,7 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class= ...@@ -615,7 +616,7 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
scan to terminate, including transactions used by any phase of concurrent scan to terminate, including transactions used by any phase of concurrent
index builds on other tables, if the indexes involved are partial or have index builds on other tables, if the indexes involved are partial or have
columns that are not simple column references. columns that are not simple column references.
Then finally the index can be marked ready for use, Then finally the index can be marked <quote>valid</quote> and ready for use,
and the <command>CREATE INDEX</command> command terminates. and the <command>CREATE INDEX</command> command terminates.
Even then, however, the index may not be immediately usable for queries: Even then, however, the index may not be immediately usable for queries:
in the worst case, it cannot be used as long as transactions exist that in the worst case, it cannot be used as long as transactions exist that
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment