Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value - Mailing list pgsql-general

From Mark Dilger
Subject Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value
Date
Msg-id 7E725C6A-CC72-41E9-B9E8-D55B7F5E63C3@enterprisedb.com
Whole thread Raw
In response to Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value  (Michael Lewis <mlewis@entrata.com>)
List pgsql-general

> On Nov 9, 2021, at 1:24 PM, Michael Lewis <mlewis@entrata.com> wrote:
>
> Is there any advantage to not defining the default on the replica? If it is not a static value and the publishing
databasewill trigger row updates, I could see waiting to set the default until after the table re-write is done, but
otherwisethere doesn't seem to be any benefit to skipping column defaults on subscribers. 

That's a schema design decision.  I can't really make recommendations in the abstract.  As a general rule, I would
expectthat the DDL executed on the publisher (such as the ALTER TABLE..ADD COLUMN..DEFAULT..) would be the same as that
executedon the subscriber, unless there is a particular reason to want different behavior on the subscriber. 

Wanting different behavior is not unreasonable.  For example, if the subscriber exists merely to archive data from the
publisher,the subscriber might not bother creating indexes over that data, even if such indexes exist on the publisher.


—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company






pgsql-general by date:

Previous
From: Michael Lewis
Date:
Subject: Re: Logical Replication - Should Destination Table Columns Be Defined With Default Value
Next
From: SQL Padawan
Date:
Subject: Understanding the differences between Temporal tables, CDC and Time Series.