Logical replication
Logical replication allows us to stream logical data changes between two nodes. By logical, we mean streaming changes to data without referring to specific physical attributes such as a block number or row ID.
These are the main benefits of logical replication:
- Performance is roughly two times better than that of the best trigger-based mechanisms.
- Selective replication is supported, so we don’t need to replicate the entire database.
- Replication can occur between different major releases, which can allow a zero-downtime upgrade.
PostgreSQL provides a feature called logical decoding, which can be used to stream a set of changes out of a primary server. This allows a primary and, since PostgreSQL 16, a standby to become a sending node in logical replication. The receiving node uses a logical replication process to receive and apply those changes, thereby implementing replication between those two nodes.
So far, we have...