Theo Kramer <theo@flame.co.za> writes:
> Tom Lane wrote:
>> We need to push awareness of the output ordering requirement down into
>> the code that chooses the basic plan. It's on the TODO list (or should
>> be) but I dunno when someone will get around to it.
> I can't wait :-)
I am about to do some major hacking on the planner/optimizer's
representation of path sort orders (for anyone who cares, PathOrder data
is going to be merged into the pathkeys structures). After the dust
settles, I will see what I can do with this issue --- it might be pretty
easy once the data structures are cleaned up.
Aside from the case with an ORDER BY clause, I believe the planner is
currently too dumb to exploit a pre-sorted path for GROUP BY. It
always puts in an explicit sort on the GROUP BY keys ...
regards, tom lane