Database: logical replication
Logical replication in Postgres decodes the write-ahead log into row changes instead of replaying bytes. The course compares it with physical replication, then covers publications, subscriptions and replication slots. It explains the wal_level setting, the restart needed to change it and its permanent WAL cost. It shows how replica identity lets updates and deletes find the right row. It looks at where logical replication fits, such as major version upgrades, and where a batch export or a cache is simpler. It ends with stopped subscribers, full disks, schema drift and conflicts.
What you'll learn
- ✓How physical and logical replication differ in what they copy and allow
- ✓How publications, subscriptions and replication slots work together
- ✓What wal_level must be set to, and what changing it costs
- ✓How replica identity identifies rows for updates and deletes
- ✓Where logical replication fits, such as major version upgrades
- ✓How it fails: stopped subscribers, full disks, schema drift and conflicts
Physical versus logical
The senior course "Database architecture: replicas" described physical replication. Logical replication is a different mechanism with a different purpose, and the difference is the whole subject.
Read the full lesson free →Curriculum
7 lessonsPhysical versus logical
Compares physical replication, which replays WAL bytes, with logical replication, which decodes them into row changes.
Publications and subscriptions
Explains publications, subscriptions and replication slots, and why schema is never replicated between the two databases.
wal_level and what it costs
Covers the three wal_level settings, the restart needed to reach logical, and the permanent extra WAL it writes.
Replica identity
Shows how replica identity lets updates and deletes find the right row, and why FULL is expensive.
What it is actually for
Describes the uses of logical replication, such as major version upgrades, and where simpler tools fit better.
The ways it breaks
Walks through the failure modes: stopped subscribers, slots that fill the publisher's disk, schema drift and conflicts.
Putting it together
Reviews the course and sets a challenge: a check that lists the tables that would fail to replicate.