Re: ORDER BY and DISTINCT ON - Mailing list pgsql-hackers

From Bruno Wolff III
Subject Re: ORDER BY and DISTINCT ON
Date
Msg-id 20031214002236.GB30707@wolff.to
Whole thread Raw
In response to ORDER BY and DISTINCT ON  (Neil Conway <neilc@samurai.com>)
List pgsql-hackers
On Fri, Dec 12, 2003 at 18:39:20 -0500, Neil Conway <neilc@samurai.com> wrote:
>         /*
>          * If the user writes both DISTINCT ON and ORDER BY, then the
>          * two expression lists must match (until one or the other
>          * runs out).  Otherwise the ORDER BY requires a different
>          * sort order than the DISTINCT does, and we can't implement
>          * that with only one sort pass (and if we do two passes, the
>          * results will be rather unpredictable). However, it's OK to
>          * have more DISTINCT ON expressions than ORDER BY
>          * expressions; we can just add the extra DISTINCT values to
>          * the sort list, much as we did above for ordinary DISTINCT
>          * fields.
>          *
>          * Actually, it'd be OK for the common prefixes of the two
>          * lists to match in any order, but implementing that check
>          * seems like more trouble than it's worth.
>          */
> 
> Does this strike anyone else as being wrong?

These seem like reasonable restrictions. There are easy work arounds
for the above restrictions, so the restrictions aren't a significant burden.

In a world with unlimited developer resources it would be nice to be able
to properly handle any order by list. In the real world I doubt that
that benefit is worth having a major developer work on this rather
than working on any of a number of other things which will result in
more benefit.


pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: WITH clause
Next
From: Greg Stark
Date:
Subject: Re: WITH clause