2 Chapter 29. Logical Replication
8 29.1.1. Replica Identity
12 29.2.1. Replication Slot Management
13 29.2.2. Examples: Set Up Logical Replication
14 29.2.3. Examples: Deferred Replication Slot Creation
16 29.3. Logical Replication Failover
19 29.4.1. Row Filter Rules
20 29.4.2. Expression Restrictions
21 29.4.3. UPDATE Transformations
22 29.4.4. Partitioned Tables
23 29.4.5. Initial Data Synchronization
24 29.4.6. Combining Multiple Row Filters
31 29.6. Generated Column Replication
36 29.9.1. Initial Snapshot
40 29.12. Configuration Settings
47 29.13.1. Prepare for Publisher Upgrades
48 29.13.2. Prepare for Subscriber Upgrades
49 29.13.3. Upgrading Logical Replication Clusters
53 Logical replication is a method of replicating data objects and their
54 changes, based upon their replication identity (usually a primary key).
55 We use the term logical in contrast to physical replication, which uses
56 exact block addresses and byte-by-byte replication. PostgreSQL supports
57 both mechanisms concurrently, see Chapter 26. Logical replication
58 allows fine-grained control over both data replication and security.
60 Logical replication uses a publish and subscribe model with one or more
61 subscribers subscribing to one or more publications on a publisher
62 node. Subscribers pull data from the publications they subscribe to and
63 may subsequently re-publish data to allow cascading replication or more
64 complex configurations.
66 When logical replication of a table typically starts, PostgreSQL takes
67 a snapshot of the table's data on the publisher database and copies it
68 to the subscriber. Once complete, changes on the publisher since the
69 initial copy are sent continually to the subscriber. The subscriber
70 applies the data in the same order as the publisher so that
71 transactional consistency is guaranteed for publications within a
72 single subscription. This method of data replication is sometimes
73 referred to as transactional replication.
75 The typical use-cases for logical replication are:
76 * Sending incremental changes in a single database or a subset of a
77 database to subscribers as they occur.
78 * Firing triggers for individual changes as they arrive on the
80 * Consolidating multiple databases into a single one (for example for
82 * Replicating between different major versions of PostgreSQL.
83 * Replicating between PostgreSQL instances on different platforms
84 (for example Linux to Windows)
85 * Giving access to replicated data to different groups of users.
86 * Sharing a subset of the database between multiple databases.
88 The subscriber database behaves in the same way as any other PostgreSQL
89 instance and can be used as a publisher for other databases by defining
90 its own publications. When the subscriber is treated as read-only by
91 application, there will be no conflicts from a single subscription. On
92 the other hand, if there are other writes done either by an application
93 or by other subscribers to the same set of tables, conflicts can arise.