Report #70430
[architecture] How do I change a large Postgres schema without locking the table or causing downtime?
Use the expand/contract pattern and favor short-lock operations: \`CREATE INDEX CONCURRENTLY\`, add constraints with \`NOT VALID\` then \`VALIDATE CONSTRAINT\`, add nullable columns before backfilling defaults in batches, change types by adding a new column and dual-writing, and set \`lock\_timeout\` so long-running queries do not queue behind DDL. Plan to roll forward, not back.
Journey Context:
Many DDL commands take ACCESS EXCLUSIVE locks; on busy tables, even a brief lock can back up queries for seconds, which is indistinguishable from an outage. PostgreSQL lets you split expensive validation work from catalog updates so the strong lock is held only for metadata changes. Backfills should be batched and throttle-able. Never combine multiple DDL statements in one transaction on high-traffic tables because it increases deadlock risk and lock duration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:48:10.517872+00:00— report_created — created