0

I'm using logical replication to move data from postgres to a search engine via some background process, but I am only concerned with a small set of tables. Is there a way to specify which tables a replication slot is concerned with

I have a replication user set up and am able to receive the changes just fine. I've implemented little script to handle the binary protocol and forward to my search engine with:

START_REPLICATION SLOT <SLOT NAME> LOGICAL 0/00000000

But this gives me every change for every table. I see that this is possible between postgres servers via publications and subscriptions, but this doesn't seem to work from an application client. Maybe I am missing something?

Is there a way to whitelist tables for replication slots this way?

2
  • I am facing a similar issue. Is there a solution to restrict a table from writing to a replication? Even if we set the REPLICA IDENTITY to 'NOTHING', it still writes INSERT data in replication slots. – sumeer arora Nov 25 '20 at 22:40
  • @Eric . We are also trying to do something similar. We used PgSync (github.com/toluaina/pgsync). However we face some issues with it as it also depends on replication slots and triggers. the replication slots seems to clone entries for every table even though we need it only for a few. More about the issues here - github.com/toluaina/pgsync/issues/62 I would appreciate if you could share more about the solution if you were able to solve it. – Krishna Prasad Varma Jan 4 at 13:58
0

Have you tried specifing the list of tables to be logically replicated while creating the publisher?

Create publisher pub_1 for table table_a;
Create subscription sub_1 publication pub_1;

This will send the changes only for table_a to the subscriber. This is the way to whitelist a selected set of tables to replicate.

ALTER PUBLICATION name ADD TABLE table_b;

This Alter publication command can be used to add/remove any tables after creating a publication.

I dont think there is a way to do this with replication slots.

1
  • 1
    Well I'm not replicating between multiple PostgreSQL instances - I'm replicating to elasticsearch. So Just using publications and subscriptions isn't really an option. I'm either going to have to use the SQL API or use the START_REPLICATION command, but the documentation doesn't specify options are available for that command. – Eric Satterwhite Oct 7 '18 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.