Re: Some revises in adding sorting path - Mailing list pgsql-hackers

From David Rowley
Subject Re: Some revises in adding sorting path
Date
Msg-id CAApHDvo6T4nMWu0KuiEmbPzaSHC6py3Ndd=oaU7WCz4wAN4nug@mail.gmail.com
Whole thread Raw
In response to Re: Some revises in adding sorting path  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: Some revises in adding sorting path
List pgsql-hackers
On Mon, 29 Jan 2024 at 22:39, Richard Guo <guofenglinux@gmail.com> wrote:
> So in the v3 patch I've brought back the logic that considers
> incremental sort on partial paths in gather_grouping_paths().  However,
> I failed to compose a test case for this scenario without having to
> generate a huge table.  So in the v3 patch I did not include a test case
> for this aspect.

Can you share the test with the huge table?

I tried and failed as, if I'm not mistaken, you're talking about a
parallel aggregate query with an incremental sort between the Partial
Aggregate node and the Finalize Group Aggregate node.  If the partial
aggregate was a Group Aggregate, then it would already be correctly
sorted.  We don't need a more strict sort ordering to perform the
Finalize Group Aggregate, the results must already be sorted by at
least the GROUP BY clause.  If the partial aggregate had opted to Hash
Aggregate, then there'd be no presorted keys, so we could only get a
full sort.  I can't see any way to get an incremental sort between the
2 aggregate phases.

What am I missing?

I also tried reverting your changes to planner.c to see if your new
tests would fail. They all passed. So it looks like none of these
tests are testing anything new.

David



pgsql-hackers by date:

Previous
From: Oleg Tselebrovskiy
Date:
Subject: Re: Returning non-terminated string in ECPG Informix-compatible function
Next
From: Alexander Kuzmenkov
Date:
Subject: Re: Incorrect cost for MergeAppend