Re: Asynchronous MergeAppend

From: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>, Matheus Alcantara <matheusssilv97(at)gmail(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Asynchronous MergeAppend
Date: 2026-10-27 11:34:50
Message-ID: CAPmGK15=KctsePnvKMNoYm3JOpuiZRWfWEfMs1GaBk9Rj45c5w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 15, 2026 at 8:34 PM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> wrote:
> I've already started reworking on Alexander
> Pyhalov's original patch for that. I will post a reworked version as
> soon as possible.

Here is an updated version of the patch, which I created with AI
assistance. In the patch I removed the changes made to both the
MergeAppendState struct and nodeMergeAppend.c so that async execution
of MergeAppend works (almost) the same as that of Append, and then
modified them in a more optimized way, which makes the patch pretty
small/simple.

Some notes about the patch:

* As for the struct, I removed from it ms_asyncresults,
ms_has_asyncresults, ms_asyncremian, ms_needrequest,
ms_valid_subplans_identified and ms_valid_asyncplans; and instead
added to it new member ms_asyncpending, which doesn't exist in
AppendState. As for the source file, I modified it based on the new
data struct, reusing some of the code in the original version.
* I adjusted the change made to create_merge_append_plan(), which
makes the original 0001 patch useless, so I removed it from the patch.
* I deduplicated the code in ExecAppendAsyncEventWait() and
ExecMergeAppendAsyncEventWait() as mentioned upthread. I didn't do so
for other functions/parts, though, because I don't strongly feel the
need for that. (I didn't include any of the proposed refactoring,
either, for the reason I mentioned upthread.)
* I modified postgresForeignAsyncConfigureWait() a bit further to work
better with async MergeAppend, and rewrote comments there.
* I did some editorialization as well, including renaming/relocating
functions like GetAppendEventSet() in the original version to match
other functions.
* I used the regression tests in the v22 patch as-proposed. I think
some comments should be updated, but I haven't done that yet.

What do you think about that? Maybe I'm missing something, though.

Best regards,
Etsuro Fujita

Attachment Content-Type Size
v23-MergeAppend-should-support-Async-Foreign-Scan-efujita.patch application/octet-stream 68.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Nisha Moond 2026-10-27 11:33:39 Re: Proposal: Conflict log history table for Logical Replication