From: andrew cooke <andrew@acooke.org>
To: pgsql-general@lists.postgresql.org
Subject: Appending data locally to a logical replication subscriber
Date: Mon, 30 May 2022 10:13:23 -0400
Message-ID: <20220530141323.y2saamlcv6y6h3zf@acooke.org> (raw)
Hi All,
I would appreciate some advice on adding data to logically replicated
tables on the subscriber. I am worried about contention between
writes from local data loading and replication.
We have 14 publisher databases (all with identical schema) that are
constantly receiving new data. The tables have a composite primary
key where one column identifies the publisher machine.
We also have a single subscriber that subscribes to all these
machines.
In addition to the realtime data described above, we would like to
back-load some archive data. For practical (ie political) reasons it
is easier to do this on the subscriber than on each publisher. The
archive data will use a composite primary key that combines the
publisher code (used to differentiate publishers) with an incremental
ID that will start at a "sufficiently large number" to avoid
conflicts.
The loading process is not a simple append; some data are normalized
in separate tables. So, for example, there may be a table with
orders, where each line is unique, but the orders reference companies
in another table, and usually these companies already exist.
My primary concern is that there is going to be contention between
replication and archive loading.
All tables on the subscriber may be queried by users (so disabling
indices is not trivial although maybe we could drop constraints and
load archive data at night).
Really, after all that, I guess I am asking the following:
- Is this just a bad idea? Is it implicit (or maybe explicit and
I've missed it) that the subscriber should be dedicated only to
reading subscriptions?
- Do subscriber transactions reflect publisher transactions? For
example, if the publisher receives many rows in a single
transaction (which can happen if we know/guess that the table is
only being written to by one process) does that mean that the
subscriber also writes those rows in a single transaction? Or is
it "simplified" to a transaction per row? Or something else (like
one transaction per "batch")?
- Is there anything else I should be concerned about?
Thanks,
Andrew
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: andrew@acooke.org
Subject: Re: Appending data locally to a logical replication subscriber
In-Reply-To: <20220530141323.y2saamlcv6y6h3zf@acooke.org>
References: <20220530141323.y2saamlcv6y6h3zf@acooke.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox