Re: Question Regarding Merge Append and Parallel Execution of Index Scans on Partitioned Table - Mailing list pgsql-hackers

From David Rowley
Subject Re: Question Regarding Merge Append and Parallel Execution of Index Scans on Partitioned Table
Date
Msg-id CAApHDvpgjbk4Nu8NMHjCAU4_suCJKR460CNOLy=BBxw6fgMmDw@mail.gmail.com
Whole thread Raw
In response to Re: Question Regarding Merge Append and Parallel Execution of Index Scans on Partitioned Table  (Ayush Vatsa <ayushvatsa1810@gmail.com>)
Responses Re: Question Regarding Merge Append and Parallel Execution of Index Scans on Partitioned Table
List pgsql-hackers
On Fri, 6 Jun 2025 at 01:47, Ayush Vatsa <ayushvatsa1810@gmail.com> wrote:
> A small follow-up question - Gather merge won't gather and merge the
> output from child in sorted order, but will always need an explicit Sort
> node beneath it to do so. Correct?

Incorrect. The input node to the Gather Merge needs to be sorted by
something, and the output of the Gather Merge will be sorted by the
same thing. Gather Merge handles putting the tuples that were gathered
by parallel workers back into the order they're meant to be in.

The Gather Merge's input node could be anything that provides sorted
output. Index Scan, Merge Join, Nested Loop, Group Aggregate, etc.
Have a look at [1]

David

[1] https://github.com/postgres/postgres/blob/master/src/test/regress/expected/select_parallel.out#L713



pgsql-hackers by date:

Previous
From: Feike Steenbergen
Date:
Subject: Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them
Next
From: Robert Haas
Date:
Subject: Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them