REINDEX
is:
REINDEX CONCURRENTLY
:
REINDEX CONCURRENTLY
is slower than a plain REINDEX
. Generally speaking, REINDEX CONCURRENTLY
is recommended for
production systems that cannot tolerate temporarily blocked writes.
In order for
REINDEX CONCURRENTLY
to succeed, Postgres requires that the
session that is executing the command remain open. If the session is closed,
Postgres will cancel the reindex. This is relevant if you are using a
connection pooler like pgbouncer
, which can be configured to terminate
sessions after a certain idle timeout is reached.If
REINDEX CONCURRENTLY
fails or is cancelled, an invalid transient index will be left behind that must be dropped manually.
To check for invalid indexes in psql
, run \d <table_name>
and look for indexes suffixed by _ccnew
.