Re: Fix up grouping sets reorder
Andrew Gierth <andrew@tao11.riddles.org.uk>
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Richard Guo <riguo@pivotal.io>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>,
Andres Freund <andres@anarazel.de>
Date: 2019-06-30T23:00:33Z
Lists: pgsql-hackers
>>>>> "Richard" == Richard Guo <riguo@pivotal.io> writes:
Richard> Hi all,
Richard> During the reorder of grouping sets into correct prefix order,
Richard> if only one aggregation pass is needed, we follow the order of
Richard> the ORDER BY clause to the extent possible, to minimize the
Richard> chance that we add unnecessary sorts. This is implemented in
Richard> preprocess_grouping_sets --> reorder_grouping_sets.
Richard> However, current codes fail to do that.
You're correct, thanks for the report.
Your fix works, but I prefer to refactor the conditional logic slightly
instead, removing the outer if{}. So I didn't use your exact patch in
the fix I just committed.
--
Andrew (irc:RhodiumToad)
Commits
-
Repair logic for reordering grouping sets optimization.
- 4a36c77156f2 9.5.19 landed
- 793eb94e3138 9.6.15 landed
- a1637caee9c7 10.10 landed
- 05dc5f4767e1 11.5 landed
- da53be23d1c5 12.0 landed