Re: Remove useless GROUP BY columns considering unique index - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Remove useless GROUP BY columns considering unique index
Date
Msg-id bdd253fc-22c6-4d29-8f0e-79bf47961e67@eisentraut.org
Whole thread Raw
In response to Re: Remove useless GROUP BY columns considering unique index  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Remove useless GROUP BY columns considering unique index
List pgsql-hackers
On 12.09.24 03:43, David Rowley wrote:
> On Sat, 30 Dec 2023 at 04:05, Zhang Mingli <zmlpostgres@gmail.com> wrote:
>> So my patch make it easy: check unique index’s columns, it’s a valid candidate if all of that have NOT NULL
constraint.
>> And we choose a best one who has the least column numbers in get_min_unique_not_null_attnos(), as the reason: less
columnsmean that more group by columns could be removed.
 
> 
> This patch no longer applies.  We no longer catalogue NOT NULL
> constraints, which this patch is coded to rely upon.

Work is ongoing to revive the patch that catalogs not-null constraints: 
<https://commitfest.postgresql.org/49/5224/>.  This patch should 
probably wait for that patch at the moment.

> (Likely it could just look at pg_attribute.attnotnull instead)

That won't work because you can't record dependencies on that.  (This is 
one of the reasons for cataloging not-null constraints as real constraints.)




pgsql-hackers by date:

Previous
From: shveta malik
Date:
Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation
Next
From: David Rowley
Date:
Subject: Re: Remove useless GROUP BY columns considering unique index