Replicating meaning not bytes
Logical replication copies changes as logical row operations rather than raw disk blocks. The source decodes its write ahead log into insert, update, and delete events and ships them to subscribers.
Publications and subscriptions
The model has two sides:
- A publication on the source declares which tables and which operations to publish.
- A subscription on the target connects to that publication and applies the changes into matching tables.
Because changes are logical, the subscriber can run a different major version, have extra tables, or carry its own indexes. You can replicate a subset of tables rather than the whole cluster.
What it enables
- Selective replication of only the tables you care about.
- Major version upgrades with near zero downtime by replicating into a newer cluster.
- Consolidating several databases into one reporting target.
Limits to know
- It does not replicate schema changes, sequences advancing, or large objects automatically.
- The publisher needs a replication slot so unconsumed changes are retained, which can grow the log if a subscriber falls behind.
Key idea
Logical replication decodes the write ahead log into row level events that a publication exposes and a subscription applies, enabling selective, cross version copies that physical replication cannot do.