Skip to main content

require-concurrent-reindex

problem

REINDEX without CONCURRENTLY requires an ACCESS EXCLUSIVE lock on the index's table, blocking reads and writes.

solution

Use REINDEX ... CONCURRENTLY.

Instead of:

-- blocks reads and writes
REINDEX TABLE foo;
REINDEX INDEX foo_idx;

Use:

-- avoids blocking reads and writes
REINDEX TABLE CONCURRENTLY foo;
REINDEX INDEX CONCURRENTLY foo_idx;