Re: Report bytes and transactions actually sent downtream - Mailing list pgsql-hackers

From Ashutosh Sharma
Subject Re: Report bytes and transactions actually sent downtream
Date
Msg-id CAE9k0PnajePcVKZPCF7o=0s6dga19HL0sKJxF4+v4y6R2aom5w@mail.gmail.com
Whole thread
In response to Re: Report bytes and transactions actually sent downtream  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers
Hi,

On Thu, Jun 25, 2026 at 4:37 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
>
> The proposed column name 'sent_bytes' is also confusing to me, because
> I don't think we can call it "total bytes actually sent" in the
> logical decoding SQL API case. A name like 'plugin_total_bytes' seems
> more straightforward and conveys the intent that protocol messages are
> not included.
>

Thank you for sharing your perspective. I agree that sent bytes
doesn't entirely reflect the bytes transmitted over the wire, rather,
it represents the total bytes emitted during the output plugin write
cycle.

In the walsender path, currently sent bytes = ctx->out->len + 1, which includes:
- plugin output
- 25-byte WALData header added by OutputPluginPrepareWrite()
- 1-byte CopyData message type

In the SQL path, sent bytes = ctx->out->len + 12, which includes:
- plugin output
- XLogRecPtr
- XID tuple column payloads

With this in mind, it may be worth considering a rename for sent bytes
to plugin_total_bytes, or maybe plugin_output_bytes, or simply
output_bytes. That said, it would be great to hear what others think
before making a decision.

--
With Regards,
Ashutosh Sharma.



pgsql-hackers by date:

Previous
From: Kirill Reshke
Date:
Subject: psql internals queries breaks in presence of user-defined operators
Next
From: Xuneng Zhou
Date:
Subject: Re: [WIP] Pipelined Recovery