Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ulUb7-001VHb-Fc for pgsql-general@arkaria.postgresql.org; Mon, 11 Aug 2025 15:38:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ulUb6-001nX6-0T for pgsql-general@arkaria.postgresql.org; Mon, 11 Aug 2025 15:38:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ulUb5-001nWy-Ly for pgsql-general@lists.postgresql.org; Mon, 11 Aug 2025 15:38:03 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ulUb3-0002Vg-14 for pgsql-general@lists.postgresql.org; Mon, 11 Aug 2025 15:38:02 +0000 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3e406ca2d22so24206375ab.1 for ; Mon, 11 Aug 2025 08:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754926681; x=1755531481; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=D771U+/5rMw7MDb9CnrLZl3Vz6yEFJqrXRizdwYSQgo=; b=BBukCX84rg5A/RBWXcgcTf5vk+3iIn36TVveeO/99XinTos+YtAvxXQesM7m1ODxgb Eoxnbx7uVY4LYtPydaozlTosq/ND+aQDi7cNZXMPouN/PKG1zB6nN9QirW1U4DYGg2ya BGWiz2iqDpKZp3YiqILhhsYFaa1sxSCBzR1ncgY6zniEsEpQYL+Z6r9151PGqS2zREST 5urYsmvLUdJtauAOmxDFZ4DE62fb1h+uvSvX0Bq36LPr+wE40v+GOdfKz/7P7lvPK7ue eoqw1pj5OQxr+G1iB0gPsj6ggoyRTudFlnUnRgWpRsycXguiZCgNbBaGqYvro3i2TBzn x76A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754926681; x=1755531481; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D771U+/5rMw7MDb9CnrLZl3Vz6yEFJqrXRizdwYSQgo=; b=JdNLBLvrxO/orNAXUFnzhzKbRvvSWH44NRmCo/THu1JD//Q+bPgXguIyyz30SExPKw lUOSYxd/w/RrYDb0naO+TBuaozbCtMGJMu6Z4Vx7uq2HOJqrZUdsqNKKNbT8/mefOyJV 7+cbrN/5UWMfq0G9Ij4HIvwyp1IUCG2O4dYMB+vb9EKYwd1OPhYT4eoXgP0cJL9zF2su JEVkal/OneJ2PTA1fJeR/o6Oe90SLu2eOMK7urcpEGAAr0RUuSdS0vVdtCGP9PHI7n+I LlYg8rqKKA3sACPkyf4VTtYfIW1Isc91pIBVFGvMDqbpB4hvYdpupZ2XsAVTISwyxNOv jgdg== X-Gm-Message-State: AOJu0YyNQmyR6omGUVI4FEBSAjX2eKgVWuk9ISy+fAqu2TNOISbnNF4b oX8gG2qYJNicgQwJp2zrDFV8pluyb84qAEGXjv5LiH2Gac6xC9IvA7gbfFcDTOtfVlh5qc86dIn Kul5zoL1Lz5OdMyHNNQx3gp9BWcpsgXiX+jZr X-Gm-Gg: ASbGnctId3L/U/NZ7XkgIt/EZyK0CRpVcUgE8Q/rKJEEkyS9HoYiY9Kc77VWXpFAgFt 3acHAZZwC1OB1XAkpEvalAAwqoJyeLp/NtaMTSe7i/mMkvHFG2SSY5NVpBl+jigNwpqrEOiCxWY 6Jbv6b1rANC1ck/GMQY1y4PQa3p4HSSd3eoBMov+QI+Va1aCWp4UjqYW2iVo1DU4SCAVqa1HWvV oTBF8Lj3/5eb6ewxzziQ2H8q7STWDmBVyi1kem87g== X-Google-Smtp-Source: AGHT+IEUgfr5kNGDCn0HWzcWX3XxLqNFzNmiKE1cF36dpb+91aR6JbE+k9YfWNQrS9ivA1DkfPyWOX5n6oMabhVdivU= X-Received: by 2002:a92:cdac:0:b0:3e5:4154:40fd with SMTP id e9e14a558f8ab-3e54163873amr156438095ab.1.1754926680841; Mon, 11 Aug 2025 08:38:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Mon, 11 Aug 2025 11:37:26 -0400 X-Gm-Features: Ac12FXzuvIQNKcr3hceP8uFTegbNGPFM4vBJrMBdoikf1LO9cXxeNnNdkUuT-bA Message-ID: Subject: Re: Can postgres replication slot using pgoutput release multiple CDC records for a single update to a particular row To: Akashkiran Shivakumar Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000006b1fab063c18b5d1" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006b1fab063c18b5d1 Content-Type: text/plain; charset="UTF-8" > > 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 --0000000000006b1fab063c18b5d1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
possible= that a single update statement could spill over as multiple CDC update=C2= =A0records=C2=A0by pgoutput=C2=A0/ postgres=C2=A0?=C2=A0
<= br>
Basically, no. If I understand your=C2=A0questions correctly,= the=C2=A0answer 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 = =3D one WAL entry =3D one pgoutput=C2=A0update. (It would be good to get fa= miliar with the pg_waldump program and examine the WAL yourself to get an i= dea of the exact changes that are generated for various situations.) While = there are cases in which a single SQL update can generate multiple WAL entr= ies (e.g. indexes, TOAST), each individual update is always going to genera= te 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=C2=A0combine 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 a= re welcome to do so, of course - as long as it's in the same transactio= n. 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 re= ason 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.<= /div>

Cheers,
Greg
<= /div>

--0000000000006b1fab063c18b5d1--