Re: Report bytes and transactions actually sent downtream

From: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, michael(at)paquier(dot)xyz, bertranddrouvot(dot)pg(at)gmail(dot)com, andres(at)anarazel(dot)de, shveta(dot)malik(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Report bytes and transactions actually sent downtream
Date: 2026-06-25 07:31:04
Message-ID: CAE9k0PnajePcVKZPCF7o=0s6dga19HL0sKJxF4+v4y6R2aom5w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Jun 25, 2026 at 4:37 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Xuneng Zhou 2026-06-25 07:47:20 Re: [WIP] Pipelined Recovery
Previous Message Chao Li 2026-06-25 07:11:29 Re: Reject unsupported COPY FROM targets before analyzing WHERE clause