Why has_useful_pathkeys() needs to check group_pathkeys

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Subject: Why has_useful_pathkeys() needs to check group_pathkeys
Date: 2025-10-09 09:36:58
Message-ID: CAMbWs4_zW5QU=Zk32s17p8qWY+ga-3ZUTons+y+Wopguiopm4A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While reviewing the recent changes in truncate_useless_pathkeys(), I
noticed the nearby function has_useful_pathkeys(), and I'm a bit
confused. It makes sense to check whether the given relation is
involved in joins or whether root->query_pathkeys is nonempty, but I
don't understand the need to specifically check root->group_pathkeys.

If the intention is to check whether there are useful pathkeys for
grouping, I think checking root->query_pathkeys is sufficient. This
is because when group_pathkeys is nonempty, standard_qp_callback()
ensures that query_pathkeys is also nonempty.

'git log' shows that the check for root->group_pathkeys was introduced
in commit 0452b461b. So cc'ing Alexander.

- Richard

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2025-10-09 09:37:55 Re: Logical Replication of sequences
Previous Message Chao Li 2025-10-09 09:35:06 Add downloaded files to gitignore