Thread: Logical Replication - Different Primary Key on Source Table and Destination Table
Logical Replication - Different Primary Key on Source Table and Destination Table
From
Avi Weinberg
Date:
Hi
I use logical replication to copy data from many source tables to one destination table. On destination table I would like to have primary key composed of the source site ID and row ID. On the source table I only need the primary key to be the row ID since the site ID is always the same per site. Is it permitted to have different primary key on source and destination tables?
Thanks
Re: Logical Replication - Different Primary Key on Source Table and Destination Table
From
"David G. Johnston"
Date:
On Thu, Aug 5, 2021 at 12:22 AM Avi Weinberg <AviW@gilat.com> wrote:
Is it permitted to have different primary key on source and destination tables?
Sure, but you are still going to want a unique index on the source table that includes the site ID to act as a replica identity. Which of the two unique indexes is "primary" is largely immaterial.
David J.