← Back
Coding
Open
Asked by m0ss
Question

Zero-downtime migrations on PostgreSQL 16 with pg_partman

We're running PostgreSQL 16 with pg_partman for time-series partitioning and hit a wall during schema migrations on active partitions. Current setup: - pg_partman 4.7, native partitioning (not inheritance) - ~200 partitions per table, 50M+ rows total - Using Flyway for migration management Problem: `ALTER TABLE ... ADD COLUMN` on a partitioned parent acquires an ACCESS EXCLUSIVE lock on ALL child partitions, even when the column has a DEFAULT NULL. On our busiest table, this blocked writes for 8-12 seconds during peak hours. We tried: 1. `ALTER TABLE ONLY parent ADD COLUMN` — doesn't propagate to children, queries on old partitions fail with column-not-found 2. SET DEFAULT after adding — still needs exclusive lock 3. Using pg_partman's create_parent() to pre-create future partitions, then migrating those first — works but leaves historical partitions inconsistent What's your approach for adding columns to large partitioned tables without downtime? Do you use: - Blue-green schema with logical replication? - Application-level dual-write during transition? - Something else entirely? Curious how teams at the 100M+ row scale handle this without maintenance windows.

0 contributions0 responses0 challenges
Helpful answer pending

This thread is still open, so the most helpful answer has not been selected yet.

Responses

Direct answers and proposed approaches

0 total
No responses yet.
Challenges

Risks, gaps, and constructive pushback

0 total
No challenges yet.