From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | Zhang Mingli <zmlpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Remove useless GROUP BY columns considering unique index |
Date: | 2024-11-27 06:51:07 |
Message-ID: | CACJufxGtnCUSAF3R4gX_E8yCm6T7MQAcLguwa50uQJDKs9LF4Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Nov 22, 2024 at 9:24 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> overall i come up with the attached patch.
in v2:
create table t1 (a int, b int not null, c int, unique(b, c));
explain(costs off) select count(*) from t1 group by b,c,a;
QUERY PLAN
----------------------
HashAggregate
Group Key: b
-> Seq Scan on t1
so the v2 implementation is wrong.
I overlooked cases like: only part of the unique-key is not-null.
In that situation, we cannot remove useless groupby columns.
v3 attached. in v3:
QUERY PLAN
----------------------
HashAggregate
Group Key: b, c, a
-> Seq Scan on t1
Attachment | Content-Type | Size |
---|---|---|
v3-0001-remove-useless-group-by-columns-via-unique-not-nu.patch | text/x-patch | 14.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | John Naylor | 2024-11-27 07:02:23 | Re: ECPG cleanup and fix for clang compile-time problem |
Previous Message | vignesh C | 2024-11-27 06:45:27 | Re: Improve the error message for logical replication of regular column to generated column. |