CONCURRENTLY is a PostgreSQL-specific modifier that can be appended to CREATE INDEX, DROP INDEX, and REINDEX commands (and indirectly via ALTER TABLE ADD CONSTRAINT ... USING INDEX). When specified, the operation executes in multiple phases that avoid taking a strict ACCESS EXCLUSIVE lock on the table. Queries and data-modification statements can continue normally, greatly reducing downtime on large or mission-critical tables. Because the work is split into phases, the command takes longer overall, writes a bit more WAL, and cannot be executed inside an explicit transaction block (BEGIN … COMMIT). If the operation is interrupted or fails, leftover “invalid” index entries are cleaned up automatically by a subsequent DROP INDEX, REINDEX, or a fresh CONCURRENTLY attempt.
CREATE INDEX, DROP INDEX, REINDEX, VACUUM, LOCK TABLE
PostgreSQL 8.2 (CREATE INDEX CONCURRENTLY)
PostgreSQL leaves a temporary invalid index. Rerun DROP INDEX or REINDEX to clean it up, then retry.
The operation needs to commit after each phase to make catalog changes visible. Wrapping it in a user transaction would block these commits, so PostgreSQL forbids it.
It takes only a SHARE UPDATE EXCLUSIVE lock, which allows normal SELECT, INSERT, UPDATE, and DELETE but blocks other schema changes like ALTER TABLE.
Skip it for small tables where a quick ACCESS EXCLUSIVE lock is negligible or when you require maximum build speed over availability.