It's possible to use logical decoding to replicate a single table? It's possible to use logical decoding to replicate a single table? postgresql postgresql

It's possible to use logical decoding to replicate a single table?


The current version of wal2json has these options:

* `filter-tables` - tables to exclude* `add-tables`- tables to include

Usage:

pg_recvlogical -slot test_slot -o add-tables=myschema.mytable,myschema.mytable2

Reference: https://github.com/eulerto/wal2json#parameters


According to the documentation you can implement your own synchronous replication solutions by implementing streaming replication interface methods:

  • CREATE_REPLICATION_SLOT slot_name LOGICAL options
  • DROP_REPLICATION_SLOT slot_name
  • START_REPLICATION SLOT slot_name LOGICAL options

In addition to the interface above you also need to implement Logical Decoding Output plugin. In this plugin interface you need to adjust Change Callback operation, which listens to all DML operations:

The required change_cb callback is called for every individual row modification inside a transaction, may it be an INSERT, UPDATE, or DELETE. Even if the original command modified several rows at once the callback will be called individually for each row.

This is the function where you want to check particular table for replication. Also be aware of the fact that Change Callback will NOT handle UNLOGGED and TEMP tables, but I guess it is not severe limitation.