Re: Parallel Apply

From: Konstantin Knizhnik <knizhnik(at)garret(dot)ru>
To: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Parallel Apply
Date: 2025-09-17 12:21:52
Message-ID: 5a209d06-bc35-4791-8dd1-6b0af5ceb206@garret.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 17/09/2025 8:18 AM, Zhijie Hou (Fujitsu) wrote:
> On Wednesday, September 17, 2025 2:40 AM Konstantin Knizhnik <knizhnik(at)garret(dot)ru> wrote:
> I think debug_logical_replication_streaming=immediate differs from real parallel
> apply . It wasn't designed to simulate genuine parallel application because it
> restricts parallelism by requiring the leader to wait for each transaction to
> complete on commit. To achieve in-order parallel apply, each parallel apply
> worker should wait for the preceding transaction to finish, similar to the
> dependency wait in the current POC patch. We plan to extend the patch to support
> in-order parallel apply and will test its performance.

You was right.
I tried to preserve commit order with your patch (using my random update
test) and was surprised that performance penalty is quite small:

I run pgbench performing random updates using 10 clients during 100
seconds and then check how long time it takes subscriber to caught up
(seconds):

master: 488
parallel-apply no order: 74
parallel-apply preserve order: 88

So looks like serialization of commits adds not so much overhead and it
makes it possible to use it by default, avoiding all effects which may
be caused by changing commit order at subscriber.

Patch is attached (it is based on your patch) and adds
preserve_commit_order GUC.

Attachment Content-Type Size
preserve_commit_order.patch text/plain 6.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2025-09-17 12:30:19 Re: PG 18 release notes draft committed
Previous Message Marcos Pegoraro 2025-09-17 12:04:19 Re: REPACK and naming