"Peter Childs" <peterachilds@gmail.com> writes:
> Is it actually in the sql spec to sort in a distinct
No. PG's code that supports GROUP BY is newer and smarter than the code
that supports DISTINCT, is all. One of the things on the to-do list is
to revise DISTINCT so it can also consider hash-based implementations.
The hard part of that is not to break DISTINCT ON ...
regards, tom lane