codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>31.1. Publication</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="logical-replication.html" title="Chapter 31. Logical Replication" /><link rel="next" href="logical-replication-subscription.html" title="31.2. Subscription" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">31.1. Publication</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="logical-replication.html" title="Chapter 31. Logical Replication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="logical-replication.html" title="Chapter 31. Logical Replication">Up</a></td><th width="60%" align="center">Chapter 31. Logical Replication</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="logical-replication-subscription.html" title="31.2. Subscription">Next</a></td></tr></table><hr /></div><div class="sect1" id="LOGICAL-REPLICATION-PUBLICATION"><div class="titlepage"><div><div><h2 class="title" style="clear: both">31.1. Publication <a href="#LOGICAL-REPLICATION-PUBLICATION" class="id_link">#</a></h2></div></div></div><p>3 A <em class="firstterm">publication</em> can be defined on any physical4 replication primary. The node where a publication is defined is referred to5 as <em class="firstterm">publisher</em>. A publication is a set of changes6 generated from a table or a group of tables, and might also be described as7 a change set or replication set. Each publication exists in only one database.8 </p><p>9 Publications are different from schemas and do not affect how the table is10 accessed. Each table can be added to multiple publications if needed.11 Publications may currently only contain tables and all tables in schema.12 Objects must be added explicitly, except when a publication is created for13 <code class="literal">ALL TABLES</code>.14 </p><p>15 Publications can choose to limit the changes they produce to16 any combination of <code class="command">INSERT</code>, <code class="command">UPDATE</code>,17 <code class="command">DELETE</code>, and <code class="command">TRUNCATE</code>, similar to how triggers are fired by18 particular event types. By default, all operation types are replicated.19 These publication specifications apply only for DML operations; they do not affect the initial20 data synchronization copy. (Row filters have no effect for21 <code class="command">TRUNCATE</code>. See <a class="xref" href="logical-replication-row-filter.html" title="31.3. Row Filters">Section 31.3</a>).22 </p><p>23 A published table must have a <em class="firstterm">replica identity</em> configured in24 order to be able to replicate <code class="command">UPDATE</code>25 and <code class="command">DELETE</code> operations, so that appropriate rows to26 update or delete can be identified on the subscriber side. By default,27 this is the primary key, if there is one. Another unique index (with28 certain additional requirements) can also be set to be the replica29 identity. If the table does not have any suitable key, then it can be set30 to replica identity <code class="literal">FULL</code>, which means the entire row becomes31 the key. When replica identity <code class="literal">FULL</code> is specified,32 indexes can be used on the subscriber side for searching the rows. Candidate33 indexes must be btree, non-partial, and the leftmost index field must be a34 column (not an expression) that references the published table column. These35 restrictions on the non-unique index properties adhere to some of the36 restrictions that are enforced for primary keys. If there are no such37 suitable indexes, the search on the subscriber side can be very inefficient,38 therefore replica identity <code class="literal">FULL</code> should only be used as a39 fallback if no other solution is possible. If a replica identity other40 than <code class="literal">FULL</code> is set on the publisher side, a replica identity41 comprising the same or fewer columns must also be set on the subscriber42 side. See <a class="xref" href="sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY"><code class="literal">REPLICA IDENTITY</code></a> for details on43 how to set the replica identity. If a table without a replica identity is44 added to a publication that replicates <code class="command">UPDATE</code>45 or <code class="command">DELETE</code> operations then46 subsequent <code class="command">UPDATE</code> or <code class="command">DELETE</code>47 operations will cause an error on the publisher. <code class="command">INSERT</code>48 operations can proceed regardless of any replica identity.49 </p><p>50 Every publication can have multiple subscribers.51 </p><p>52 A publication is created using the <a class="link" href="sql-createpublication.html" title="CREATE PUBLICATION"><code class="command">CREATE PUBLICATION</code></a>53 command and may later be altered or dropped using corresponding commands.54 </p><p>55 The individual tables can be added and removed dynamically using56 <a class="link" href="sql-alterpublication.html" title="ALTER PUBLICATION"><code class="command">ALTER PUBLICATION</code></a>. Both the <code class="literal">ADD57 TABLE</code> and <code class="literal">DROP TABLE</code> operations are58 transactional; so the table will start or stop replicating at the correct59 snapshot once the transaction has committed.60 </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="logical-replication.html" title="Chapter 31. Logical Replication">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="logical-replication.html" title="Chapter 31. Logical Replication">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="logical-replication-subscription.html" title="31.2. Subscription">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 31. Logical Replication </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 31.2. Subscription</td></tr></table></div></body></html>