On Thu, 9 May 2024 at 13:08, David Rowley <dgrowle...@gmail.com> wrote: > 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.
Another argument for using this method is that SupportRequestOptimizeAggref could allow future unrelated optimisations such as swapping count(<non-nullable-col>) for count(*). Where <non-nullable-col> is a NOT NULL column and isn't nullable by any outer join. Doing that could speed some queries up quite a bit as it may mean fewer columns to deform from the tuple. You could imagine a fact table with many columns and a few dimensions, often the dimension columns that you'd expect to use in GROUP BY would appear before the columns you'd aggregate on. David