postgresql/src/backend/optimizer/path
Alexander Korotkov 505c008ca3 Restore preprocess_groupclause()
0452b461bc made optimizer explore alternative orderings of group-by pathkeys.
It eliminated preprocess_groupclause(), which was intended to match items
between GROUP BY and ORDER BY.  Instead, get_useful_group_keys_orderings()
function generates orderings of GROUP BY elements at the time of grouping
paths generation.  The get_useful_group_keys_orderings() function takes into
account 3 orderings of GROUP BY pathkeys and clauses: original order as written
in GROUP BY, matching ORDER BY clauses as much as possible, and matching the
input path as much as possible.  Given that even before 0452b461b,
preprocess_groupclause() could change the original order of GROUP BY clauses
we don't need to consider it apart from ordering matching ORDER BY clauses.

This commit restores preprocess_groupclause() to provide an ordering of
GROUP BY elements matching ORDER BY before generation of paths.  The new
version of preprocess_groupclause() takes into account an incremental sort.
The get_useful_group_keys_orderings() function now takes into 2 orderings of
GROUP BY elements: the order generated preprocess_groupclause() and the order
matching the input path as much as possible.

Discussion: https://postgr.es/m/CAPpHfdvyWLMGwvxaf%3D7KAp-z-4mxbSH8ti2f6mNOQv5metZFzg%40mail.gmail.com
Author: Alexander Korotkov
Reviewed-by: Andrei Lepikhov, Pavel Borisov
2024-06-06 13:44:34 +03:00
..
allpaths.c Re-allow planner to use Merge Append to efficiently implement UNION. 2024-05-21 12:44:51 -04:00
clausesel.c Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
costsize.c Do not translate dummy SpecialJoinInfos for child joins 2024-03-25 18:06:47 +09:00
equivclass.c Fix asymmetry in setting EquivalenceClass.ec_sortref 2024-06-06 13:41:34 +03:00
indxpath.c Revert: Remove useless self-joins 2024-05-06 14:36:36 +03:00
joinpath.c Postpone reparameterization of paths until create_plan(). 2024-03-19 14:51:58 -04:00
joinrels.c Code review for 6190d828cd 2024-03-25 19:45:27 +09:00
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
pathkeys.c Restore preprocess_groupclause() 2024-06-06 13:44:34 +03:00
tidpath.c Prevent RLS filters on ctid from breaking WHERE CURRENT OF <cursor>. 2024-05-07 13:35:10 -04:00