Re: Warts with SELECT DISTINCT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Warts with SELECT DISTINCT
Date: 2006-05-04 05:13:20
Message-ID: 18946.1146719600@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> Greg Stark <gsstark(at)mit(dot)edu> wrote [ baldly summarized ]
>> [ x > y implies upper(x) > upper(y) ]

> I don't think you can assume that that will be true for any locale.

Whether or not that may actually be true for upper() (I share Bruno's
skepticism, but maybe it's so), it really does not matter because the
planner doesn't have enough knowledge about the behavior of upper() to
make such an inference.

I think it's a fair point that we could allow "SELECT DISTINCT x ORDER BY
foo(x)" if foo() is stable, but that does not imply that sorting by x is
interchangeable with sorting by foo(x). foo = abs is a trivial
counterexample.

As far as the original point goes: feel free to reimplement DISTINCT,
but don't break the documented behavior of DISTINCT ON + ORDER BY, or
you'll have a lot of unhappy villagers appear on your doorstep bearing
torches and pitchforks. It might be mostly an implementation artifact,
but it's an awfully useful one ...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dhanaraj M 2006-05-04 05:19:27 current version: Patch - Have psql show current values for a sequence]
Previous Message Bruno Wolff III 2006-05-04 04:50:42 Re: Warts with SELECT DISTINCT