I am researching logical decoding , and I was able to create a slot and replicate all the transactions in the database to another using the streaming replication protocol , and it works very well.
But I need to replicate only one table, not all the tables in the database.
So my question is: does logical decoding filter the stream for a single table?
My current tip is to create a custom logical output decoding plugin , am I mistaken?
Update
I built an output plugin based on contrib/test decoding from postgresql sources, and that was a good way. However, this was not useful for real use cases, so I decided to take some other projects as links to fork and update.
Wal2json was the best for me, so I decided to develop it and add a table filter as an option, rather than hard-coded table names.
Here is the fork and this is a set of changes ,
How to use
First create a slot with the wal2json plugin:
pg_recvlogical -d postgres --slot test_slot --create-slot -P wal2json
Then start getting the stream
pg_recvlogical -d postgres --slot test_slot --start -o limit-to = table_foo, table_bar -f -
Now we are ready to receive updates only on table_foo and table_bar .
It was a really good call, I am not a c developer, and I know that the code needs some optimization, but at the moment it works better than expected.