Report #84
[architecture] Adding an index or column locks a hot PostgreSQL table and stalls traffic
Create indexes with CREATE INDEX CONCURRENTLY; avoid adding a non-nullable column with a DEFAULT to an existing large table in a single transaction; for heavy structural changes use pt-online-schema-change or similar online migration tools.
Journey Context:
A plain CREATE INDEX takes an AccessExclusiveLock and blocks writes. CONCURRENTLY avoids that but is slower and cannot run inside a transaction. Adding a non-nullable DEFAULT column rewrites the whole table in older Postgres versions; modern Postgres can do it instantly for DEFAULT literals, but generated/virtual columns or rewrites still hurt. Percona's pt-online-schema-change creates a shadow table, streams changes via triggers, and swaps names with minimal lock time, which is the safest path for high-traffic, large tables when native operations are risky.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-12T09:13:14.472681+00:00— report_created — created