Re: Missing empty transaction optimization in pgoutput plugin

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tomas Vondra <tomas(at)vondra(dot)me>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: Missing empty transaction optimization in pgoutput plugin
Date: 2025-12-08 12:10:53
Message-ID: CAA4eK1K_CcjbOo8=1mKU0+nNdjM7BKPf7+Wp-SJ6t_62WhJfSw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 8, 2025 at 12:19 PM Ashutosh Bapat
<ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
>
> test_decoding output plugin skips sending stream_start and stream_end
> if no change from a segment of a streamed transaction is sent
> downstream. If no change has been sent downstream across all the
> streamed segments it doesn't send commit or abort for that streamed
> transaction. But I don't see similar changes in stream related
> callbacks in pgoutput output plugin.
>
> While the changes discussed in thread [1] were committed, those didn't
> include this optimization for test_decoding plugin as well. The
> optimization was discussed in [2] separately as a bug fix. Maybe
> because it wasn't considered as an optimization that time, we may not
> have considered it for pgoutput plugin which doesn't have explicit
> skip-empty-xacts option. I think the optimization would be useful in
> setups where multiple publications and long transactions are common.
> Any reason not to have it.
>

I don't remember any reason why we can't have the same optimization
for streamed transactions. IIRC, we implemented this optimization
because we got reports for extra messages for short empty-transactions
but if you see any practical cases where it could be useful for
streamed transactions as well then feel free to propose a patch.

--
With Regards,
Amit Kapila.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-12-08 12:14:19 Re: Skipping schema changes in publication
Previous Message Pavlo Golub 2025-12-08 12:09:58 [PATCH] Add pg_current_vxact_id() function to expose virtual transaction IDs