Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logical Replication and Declarative Partitioning in PostgreSQL 11

I have a regular table transactions with 200 million rows.

I decided to convert this table to a Declarative Partition using Logical Replication.

I created a Publication on node1 like so:

CREATE PUBLICATION transactions_pub FOR TABLE transactions;

When I try to create Subscription on node2 as below:

CREATE SUBSCRIPTION transactions_sub CONNECTION 'host=x.x.x.x port=5432 password=123456 user=replicator dbname=mydbname' PUBLICATION transactions_pub;

Returns this error:

ERROR:  logical replication target relation "public.transactions" is not a table

Is it possible to replicate a regular table to a Declarative Partition Table using Logical Replication?

like image 992
Hamed Kamrava Avatar asked Nov 30 '18 09:11

Hamed Kamrava


People also ask

What is declarative partitioning Postgres?

Declarative Partitioning. PostgreSQL allows you to declare that a table is divided into partitions. The table that is divided is referred to as a partitioned table. The declaration includes the partitioning method as described above, plus a list of columns or expressions to be used as the partition key.

What is logical replication in PostgreSQL?

Logical replication is a method of replicating data objects and their changes, based upon their replication identity (usually a primary key). We use the term logical in contrast to physical replication, which uses exact block addresses and byte-by-byte replication.

Can replication and partitioning be used together?

Replication is supported between partitioned tables as long as they use the same partitioning scheme and otherwise have the same structure except where an exception is specifically allowed (see Section 16.4. 1.10, “Replication with Differing Table Definitions on Source and Replica”).


1 Answers

No, logical replication cannot replicate from and to declarative partitioned tables.

like image 87
amitlan Avatar answered Sep 27 '22 19:09

amitlan