On Thu, 9 May 2024 at 12:26, David Rowley <dgrowle...@gmail.com> wrote: > I wonder if we should also consider as an alternative to this to just > have an aggregate support function, similar to > SupportRequestOptimizeWindowClause that just nullifies the aggorder / > aggdistinct fields for Min/Max aggregates on types where there's no > possible difference in output when calling the transition function on > rows in a different order. > > Would that apply in enough cases for you?
One additional thought is that the above method would also help eliminate redundant sorting in queries with a GROUP BY clause. Whereas, the can_minmax_aggs optimisation is not applied in that case. David