On Thu, May 04, 2006 at 01:13:20 -0400,
  Tom Lane <[EMAIL PROTECTED]> wrote:
> 
> 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.

I misunderstood Greg's example. Sorting by (foo(x), x) is a suitable
replacement for sorting by foo(x). So that it would be OK to rewrite
SELECT DISTINCT x ORDER BY foo(x)
as
SELECT DISTINCT ON (foo(x), x) x ORDER BY foo(x)

Whether or not this is worthwhile to automate, I am not in a good position
to judge.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to