Re: Remove useless GROUP BY columns considering unique index

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: jian he <jian.universality@gmail.com>
Cc: Andrei Lepikhov <lepihov@gmail.com>, Zhang Mingli <zmlpostgres@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-12T02:55:53Z
Lists: pgsql-hackers
On Mon, 2 Dec 2024 at 17:22, jian he <jian.universality@gmail.com> wrote:
> regarding v10.
> you placed remove_useless_groupby_columns right after add_base_rels_to_query
> makes so much sense.
> so we can be safely use cached RelOptInfo->indexlist, RelOptInfo->notnullattnums
> overall it didn't find any issue.

Thanks for looking.

After a bit more adjustment, I've pushed both patches.

I felt it was best to have the commit that moved
remove_useless_groupby_columns also change the call site of that
function.

David



Commits

  1. Detect redundant GROUP BY columns using UNIQUE indexes

  2. Defer remove_useless_groupby_columns() work until query_planner()