Provide a simpler version. Simplify comments and split code and regression tests. Might be far better for reviewer.
Patch 1 is a small planner-only change that
speeds up ordered aggregates under GROUP BY when the aggregate's
argument is varlena, for example
SELECT g, string_agg(v, ',' ORDER BY k) FROM t GROUP BY g;
Patch 2 adds the regression tests.
0001-Put-presorted-aggregate-sort-keys-first-in-Aggregate.patch
Description: Binary data
0002-Add-regression-tests-for-presorted-aggregate-sort-ke.patch
Description: Binary data
