|
124 | 124 | <command>TRUNCATE</command>. See <xref linkend="logical-replication-row-filter"/>). |
125 | 125 | </para> |
126 | 126 |
|
127 | | - <para> |
128 | | - A published table must have a <firstterm>replica identity</firstterm> configured in |
129 | | - order to be able to replicate <command>UPDATE</command> |
130 | | - and <command>DELETE</command> operations, so that appropriate rows to |
131 | | - update or delete can be identified on the subscriber side. By default, |
132 | | - this is the primary key, if there is one. Another unique index (with |
133 | | - certain additional requirements) can also be set to be the replica |
134 | | - identity. If the table does not have any suitable key, then it can be set |
135 | | - to replica identity <literal>FULL</literal>, which means the entire row becomes |
136 | | - the key. When replica identity <literal>FULL</literal> is specified, |
137 | | - indexes can be used on the subscriber side for searching the rows. Candidate |
138 | | - indexes must be btree or hash, non-partial, and the leftmost index field must |
139 | | - be a column (not an expression) that references the published table column. |
140 | | - These restrictions on the non-unique index properties adhere to some of the |
141 | | - restrictions that are enforced for primary keys. If there are no such |
142 | | - suitable indexes, the search on the subscriber side can be very inefficient, |
143 | | - therefore replica identity <literal>FULL</literal> should only be used as a |
144 | | - fallback if no other solution is possible. If a replica identity other |
145 | | - than <literal>FULL</literal> is set on the publisher side, a replica identity |
146 | | - comprising the same or fewer columns must also be set on the subscriber |
147 | | - side. See <xref linkend="sql-altertable-replica-identity"/> for details on |
148 | | - how to set the replica identity. If a table without a replica identity is |
149 | | - added to a publication that replicates <command>UPDATE</command> |
150 | | - or <command>DELETE</command> operations then |
151 | | - subsequent <command>UPDATE</command> or <command>DELETE</command> |
152 | | - operations will cause an error on the publisher. <command>INSERT</command> |
153 | | - operations can proceed regardless of any replica identity. |
154 | | - </para> |
155 | | - |
156 | 127 | <para> |
157 | 128 | Every publication can have multiple subscribers. |
158 | 129 | </para> |
|
169 | 140 | transactional, so the table will start or stop replicating at the correct |
170 | 141 | snapshot once the transaction has committed. |
171 | 142 | </para> |
| 143 | + |
| 144 | + <sect2 id="logical-replication-publication-replica-identity"> |
| 145 | + <title>Replica Identity</title> |
| 146 | + |
| 147 | + <para> |
| 148 | + A published table must have a <firstterm>replica identity</firstterm> |
| 149 | + configured in order to be able to replicate <command>UPDATE</command> |
| 150 | + and <command>DELETE</command> operations, so that appropriate rows to |
| 151 | + update or delete can be identified on the subscriber side. |
| 152 | + </para> |
| 153 | + |
| 154 | + <para> |
| 155 | + By default, this is the primary key, if there is one. Another unique index |
| 156 | + (with certain additional requirements) can also be set to be the replica |
| 157 | + identity. If the table does not have any suitable key, then it can be set |
| 158 | + to replica identity <literal>FULL</literal>, which means the entire row |
| 159 | + becomes the key. When replica identity <literal>FULL</literal> is |
| 160 | + specified, indexes can be used on the subscriber side for searching the |
| 161 | + rows. Candidate indexes must be btree or hash, non-partial, and the |
| 162 | + leftmost index field must be a column (not an expression) that references |
| 163 | + the published table column. These restrictions on the non-unique index |
| 164 | + properties adhere to some of the restrictions that are enforced for |
| 165 | + primary keys. If there are no such suitable indexes, the search on the |
| 166 | + subscriber side can be very inefficient, therefore replica identity |
| 167 | + <literal>FULL</literal> should only be used as a fallback if no other |
| 168 | + solution is possible. |
| 169 | + </para> |
| 170 | + |
| 171 | + <para> |
| 172 | + If a replica identity other than <literal>FULL</literal> is set on the |
| 173 | + publisher side, a replica identity comprising the same or fewer columns |
| 174 | + must also be set on the subscriber side. |
| 175 | + </para> |
| 176 | + |
| 177 | + <para> |
| 178 | + Tables with a replica identity defined as <literal>NOTHING</literal>, |
| 179 | + <literal>DEFAULT</literal> without a primary key, or <literal>USING |
| 180 | + INDEX</literal> with a dropped index, cannot support |
| 181 | + <command>UPDATE</command> or <command>DELETE</command> operations when |
| 182 | + included in a publication replicating these actions. Attempting such |
| 183 | + operations will result in an error on the publisher. |
| 184 | + </para> |
| 185 | + |
| 186 | + <para> |
| 187 | + <command>INSERT</command> operations can proceed regardless of any replica identity. |
| 188 | + </para> |
| 189 | + |
| 190 | + <para> |
| 191 | + See <link linkend="sql-altertable-replica-identity"><literal>ALTER TABLE...REPLICA IDENTITY</literal></link> |
| 192 | + for details on how to set the replica identity. |
| 193 | + </para> |
| 194 | + </sect2> |
| 195 | + |
172 | 196 | </sect1> |
173 | 197 |
|
174 | 198 | <sect1 id="logical-replication-subscription"> |
|
0 commit comments