Re: remove_useless_groupby_columns is too enthusiastic - Mailing list pgsql-hackers

From David Rowley
Subject Re: remove_useless_groupby_columns is too enthusiastic
Date
Msg-id CAApHDvozVPAYSL6h50YQ9_k3K3-0axYEgBVdr9TAKdRiM0k5hQ@mail.gmail.com
Whole thread Raw
In response to remove_useless_groupby_columns is too enthusiastic  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wed, 13 Jul 2022 at 05:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I tried the attached quick-hack patch that just prevents
> remove_useless_groupby_columns from removing anything that
> appears in ORDER BY.  That successfully fixes the complained-of
> case, and it doesn't change any existing regression test results.
> I'm not sure whether there are any cases that it makes significantly
> worse.

In addition to this, we also do a pre-verification step to see if the
ORDER BY has anything in it that the GROUP BY does not?

I don't think there's any harm in removing the GROUP BY item if the
pre-check finds something extra in ORDER BY since
preprocess_groupclause() is going to fail in that case anyway.

David



pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: making relfilenodes 56 bits
Next
From: David Rowley
Date:
Subject: Re: PG15 beta1 sort performance regression due to Generation context change