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

From David Rowley
Subject Re: Remove useless GROUP BY columns considering unique index
Date
Msg-id CAApHDvot=SgDX5euFs-GwS+mBF-N_HES0LXyip=FxgqBaAaWWg@mail.gmail.com
Whole thread Raw
In response to Remove useless GROUP BY columns considering unique index  (Zhang Mingli <zmlpostgres@gmail.com>)
Responses Re: Remove useless GROUP BY columns considering unique index
List pgsql-hackers
On Fri, 29 Nov 2024 at 20:04, jian he <jian.universality@gmail.com> wrote:
> I found that unique expression index can also be used for groupby
> column removal.
> so I implemented it, aslo added two tests on it.

> what do you think?

I think it's likely just not common enough to be worthwhile, plus,
unfortunately, I don't think this optimisation is possible with what
we have today. Also, if it were possible you'd need to check the GROUP
BY expressions match the indexed expressions. You've not done that.

The reason I don't think is possible is that we have no infrastructure
that allows us to tag functions or operators so that non-null input(s)
mean non-null outputs.  We only have strict, which means null input
means null output. That's the opposite of what we'd need. It might
only be possible with a NULLS NOT DISTINCT index.

David



pgsql-hackers by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: Logging parallel worker draught
Next
From: "Andrey M. Borodin"
Date:
Subject: Re: [PATCH] Add sortsupport for range types and btree_gist