public inbox for [email protected]  
help / color / mirror / Atom feed
From: Greg Sabino Mullane <[email protected]>
To: Akashkiran Shivakumar <[email protected]>
Cc: [email protected]
Subject: Re: Can postgres replication slot using pgoutput release multiple CDC records for a single update to a particular row
Date: Mon, 11 Aug 2025 11:37:26 -0400
Message-ID: <CAKAnmm+JEf7FWAKW4KZoERsyU9SLZg86YMDUNirtUrKnWTe7eg@mail.gmail.com> (raw)
In-Reply-To: <CADTnmPjcbW07j26AxdqAsMbSJEAdHtva7Kdazmo99twuF59whw@mail.gmail.com>
References: <CADTnmPjcbW07j26AxdqAsMbSJEAdHtva7Kdazmo99twuF59whw@mail.gmail.com>

>
> possible that a single update statement could spill over as multiple CDC
> update records by pgoutput / postgres ?


Basically, no. If I understand your questions correctly, the answer seems
to point to your application making multiple updates, which will lead to
multiple UPDATE records in the WAL, and thus multiple UPDATEs via pgoutput.
But the basic mapping will still be one heap update = one WAL entry = one
pgoutput update. (It would be good to get familiar with the pg_waldump
program and examine the WAL yourself to get an idea of the exact changes
that are generated for various situations.) While there are cases in which
a single SQL update can generate multiple WAL entries (e.g. indexes,
TOAST), each individual update is always going to generate at least one WAL
record. Due to the way that Postgres works, each update gets put into WAL
immediately - Postgres cannot merge updates that happen to occur in the
same transaction. Nor does pgoutput combine those. So even though at the
end of the transaction a single row gets changed at the logical level,
there can be quite a number of changes at the WAL level. If you want to
smush together pgoutput's updates into a single call, you are welcome to do
so, of course - as long as it's in the same transaction. But I'd not do
that, as you are now messing with the order of events as they happened on
your primary. In other words, there may have been a reason it was updated
col by col on the primary, and if that bothers you, the primary is the
place to fix it, not stitching it together after the fact.

Cheers,
Greg


view thread (3+ messages)

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Can postgres replication slot using pgoutput release multiple CDC records for a single update to a particular row
  In-Reply-To: <CAKAnmm+JEf7FWAKW4KZoERsyU9SLZg86YMDUNirtUrKnWTe7eg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox