can be used safely and easily in all cases.
- But since the command requires an exclusive table lock, it is
- often preferable to execute an index rebuild with a sequence of
- creation and replacement steps. Index types that support
- with the CONCURRENTLY
- option can instead be recreated that way. If that is successful and the
- resulting index is valid, the original index can then be replaced by
- the newly built one using a combination of
- and . When an index is used to enforce
- uniqueness or other constraints, might
- be necessary to swap the existing constraint with one enforced by
- the new index. Review this alternate multistep rebuild approach
- carefully before using it as there are limitations on which
- indexes can be reindexed this way, and errors must be handled.
+ This command requires an ACCESS EXCLUSIVE lock by
+ default, hence it is often preferable to execute it with its
+ CONCURRENTLY option which requires only a
+ SHARE UPDATE EXCLUSIVE lock.