GROUP BY reordering
Planner reordering of GROUP BY/DISTINCT keys and removal of redundant GROUP BY columns.
Versions
- PostgreSQL 20 · worked-on · improved · moderate
- PostgreSQL 18 · shipped · improved · moderate · 4 commits · +1.1k / -427 lines
- PostgreSQL 17 · shipped · improved · major · 9 commits · +1.3k / -715 lines
- PostgreSQL 16 · worked-on · improved · major
- PostgreSQL 15 · reverted · improved · major · 1 commit · +1.9k / -494 lines
- PostgreSQL 14 · worked-on · improved · major
- PostgreSQL 13 · worked-on · improved · major
- PostgreSQL 12 · worked-on · improved · major
Threads
- Preserve presorted ORDER BY keys when reordering DISTINCT ON keys
- [PATCH] Consider window functions when reordering GROUP BY items
- Wrong results from GROUP BY column removal
- Skip a redundant singleton GROUP BY node
- Wrong results in remove_useless_groupby_columns()
- Why has_useful_pathkeys() needs to check group_pathkeys
- Modify an incorrect regression test case in the group by key value elimination function
- Remove useless GROUP BY columns considering unique index
- Consider the number of columns in the sort cost model
- Reordering DISTINCT keys to match input path's pathkeys
- Missing docs for new enable_group_by_reordering GUC
- POC: GROUP BY optimization
- Get rid of the excess semicolon in planner.c
- Missing Group Key in grouped aggregate
- v17 Possible Union All Bug
- [PATCH] Teach planner to further optimize sort in distinct
- Removing redundant grouping columns
- remove_useless_groupby_columns is too enthusiastic
- Question: test "aggregates" failed in 32-bit machine
- Some clean-up work in get_cheapest_group_keys_order()
- BUG #17544: Join order for INNER JOIN ... USING with GROUP BY on join column affects selected query plan
- Group by reordering optimization
- Side effect of remove_useless_groupby_columns
- BUG #16869: GROUP BY on primary key unnecessarily triggers a full table scan
- remove_useless_groupby_columns does not need to record constraint dependencies
- Order of columns in GROUP BY is significant to the planner.