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
