Re: Add proper planner support for ORDER BY / DISTINCT aggregates
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Dean Rasheed <dean.a.rasheed@gmail.com>, Ronan Dunklau <ronan.dunklau@aiven.io>, Justin Pryzby <pryzby@telsasoft.com>, Pavel Luzanov <p.luzanov@postgrespro.ru>, pgsql-hackers@lists.postgresql.org, Ranier Vilela <ranier.vf@gmail.com>
Date: 2023-01-18T09:49:10Z
Lists: pgsql-hackers
On Wed, 18 Jan 2023 at 22:37, Richard Guo <guofenglinux@gmail.com> wrote: > I'm still confused that when the same scenario happens with ORDER BY in > an aggregate function, like in query 1, the result is different in that > we would get an unsorted output. > > I wonder if we should avoid this inconsistent behavior. It certainly seems pretty strange that aggregates with an ORDER BY behave differently from the query's ORDER BY. I'd have expected that to be the same. I've not looked to see why there's a difference, but suspect that we thought about how we want it to work for the query's ORDER BY and when ORDER BY aggregates were added, that behaviour was not considered. Likely finding the code or location where that code should be would help us understand if something was just forgotten in the aggregate's case. It's probably another question as to if we should be adjusting this behaviour now. David
Commits
-
Don't presort ORDER BY/DISTINCT Aggrefs with volatile functions
- da5800d5fa63 16.0 landed
-
Add enable_presorted_aggregate GUC
- 3226f47282a0 16.0 landed
-
Remove pessimistic cost penalization from Incremental Sort
- 4a29eabd1d91 16.0 landed
-
Fix hypothetical problem passing the wrong GROUP BY pathkeys
- af7d270dd3c7 16.0 landed
-
Remove unused fields from ExprEvalStep
- 9fc1776dda9f 16.0 landed
-
Improve performance of ORDER BY / DISTINCT aggregates
- 1349d2790bf4 16.0 landed
-
Refactor function parse_subscription_options.
- 8aafb0261675 15.0 cited