Re: Remove useless GROUP BY columns considering unique index

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: David Rowley <dgrowleyml(at)gmail(dot)com>, Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Remove useless GROUP BY columns considering unique index
Date: 2024-09-18 07:28:30
Message-ID: bdd253fc-22c6-4d29-8f0e-79bf47961e67@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12.09.24 03:43, David Rowley wrote:
> On Sat, 30 Dec 2023 at 04:05, Zhang Mingli <zmlpostgres(at)gmail(dot)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 columns mean 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.)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Anthonin Bonnefoy 2024-09-18 07:42:43 Re: [PATCH] Add additional extended protocol commands to psql: \parse and \bind
Previous Message Laurenz Albe 2024-09-18 07:27:36 Re: pgsql: Don't enter parallel mode when holding interrupts.