← all rules

reindex-non-concurrent

error

REINDEX without CONCURRENTLY

Why it's unsafe

REINDEX without CONCURRENTLY takes an ACCESS EXCLUSIVE lock on each index it rebuilds, blocking writes (and reads through that index).

Safe rewrite

Use REINDEX INDEX CONCURRENTLY (PG12+, outside a transaction); on older servers use pg_repack or a maintenance window.

Example

Try it in the playground →

Unsafe

REINDEX INDEX idx_users_email;

Safe

REINDEX INDEX CONCURRENTLY idx_users_email;

Related