Re: Some revises in adding sorting path

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Some revises in adding sorting path
Date: 2024-01-30 11:00:05
Message-ID: CAApHDvo6T4nMWu0KuiEmbPzaSHC6py3Ndd=oaU7WCz4wAN4nug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 29 Jan 2024 at 22:39, Richard Guo <guofenglinux(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Kuzmenkov 2024-01-30 11:06:28 Re: Incorrect cost for MergeAppend
Previous Message Oleg Tselebrovskiy 2024-01-30 10:56:22 Re: Returning non-terminated string in ECPG Informix-compatible function