Re: Question Regarding Merge Append and Parallel Execution of Index Scans on Partitioned Table

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Ayush Vatsa <ayushvatsa1810(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Question Regarding Merge Append and Parallel Execution of Index Scans on Partitioned Table
Date: 2025-06-05 14:06:14
Message-ID: CAApHDvpgjbk4Nu8NMHjCAU4_suCJKR460CNOLy=BBxw6fgMmDw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 6 Jun 2025 at 01:47, Ayush Vatsa <ayushvatsa1810(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-06-05 14:38:58 Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them
Previous Message Feike Steenbergen 2025-06-05 13:54:28 Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them