Can we do streaming and logical replication in postgresql Slave at same time?

Hi,

Bad news/Good news

Bad News: Unfortunately, postgres doesn’t currently support logical replication from a REPLICA/SLAVE.

Good News: Set up another read-write server and pull in the data you need from the REPLICA using the postgres foreign data wrapper.

Abbreviated example snippet, execute on pg3 (it’s not really complete, just shows the essentials):

begin;
create extension postgres_fdw;
create server pg_remote foreign data wrapper postgres_fdw options (host 'pg2', dbname 'db01', port '5432');
create user mapping for CURRENT_ROLE server pg_remote options (user 'postgres', password 'postgres');
create foreign table public.t1(id integer) server pg_remote;
commit;

Of course you’ll need to add supplementary SQL in order to keep your tables uptodate i.e. perhaps an UPSERT.

Hope this helps.