Blocking Pattern (Avoid in Production)

CREATE INDEX idx_orders_status ON billing.orders (status);

Zero-Downtime Safe Rewrite

CREATE INDEX CONCURRENTLY idx_orders_status ON billing.orders (status);

Production Rollout Notes

  • CREATE INDEX CONCURRENTLY cannot run inside an explicit BEGIN/COMMIT transaction block.
  • If it fails midway, it leaves an INVALID index behind (check pg_index.indisvalid and DROP INDEX CONCURRENTLY).