Re: ORDER BY and DISTINCT ON

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ORDER BY and DISTINCT ON
Date: 2003-12-14 00:22:36
Message-ID: 20031214002236.GB30707@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 12, 2003 at 18:39:20 -0500,
Neil Conway <neilc(at)samurai(dot)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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2003-12-14 02:56:00 Re: WITH clause
Previous Message Hannu Krosing 2003-12-13 22:27:05 Re: WITH clause