Postgres logical replication started as an alternative to physical streaming replication. Its real power is being a streaming changes feed that you can do almost anything with: zero-downtime migrations, multi-master via conflict resolution, cross-version upgrades, custom CDC. Underused outside the HA case.

Advertisement

Streaming vs logical

Streaming replication: byte-for-byte copy of WAL. Same version, same architecture. Logical replication: decodes WAL into INSERT/UPDATE/DELETE events. Different versions OK, different schemas possible. More flexible; slightly more overhead.

Zero-downtime version upgrades

Old Postgres 14 → new 17. Set up logical replication from 14 to 17. Wait for catch-up. Cut traffic. Total downtime: seconds, not the multi-hour pg_upgrade window. The pattern many large fleets use.

Advertisement

Splitting one DB into two

Replicate publications subset-by-subset to a new instance. Cut traffic for the moved tables once caught up. Combine with FDW (foreign data wrapper) for cross-DB queries during migration. Manageable in production.

Custom CDC pipelines

Subscribe to logical replication slots with pg_recvlogical or a Debezium connector. Decode to JSON, push to Kafka, do whatever. Native Postgres CDC without external tooling. Many teams don't realize this is built-in.

Caveats

DDL doesn't replicate (must run on both sides). Sequences replicate values, not state. Slot retention: consumer behind = WAL fills disk = service down. Monitor lag religiously. Replica identity FULL for tables without unique keys.

Logical replication = native Postgres CDC. Version upgrades, splits, custom pipelines. Watch slot lag carefully.