Re: ORDER BY

From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: "Harald Fuchs" <hf1110x(at)protecting(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ORDER BY
Date: 2006-11-21 03:05:34
Message-ID: 65937bea0611201905v3f5adf02r254d82cc6d26f641@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16 Nov 2006 11:04:15 +0100, Harald Fuchs <hf1110x(at)protecting(dot)net> wrote:
>
> Why so complicated?
>
> SELECT whatever FROM foo ORDER BY name = 'Other', name
>

This is by far the simplest (and intelligent) of them all. And it will use a
single scan of the underlying table (or index, if used), so should prove to
be faster than the other UNION schemes.

Another tweak: If possible, use the integer column (ID) instead of the Name
column.

Regards,

--
gurjeet[(dot)singh](at)EnterpriseDB(dot)com
singh(dot)gurjeet(at){ gmail | hotmail | yahoo }.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-11-21 03:30:31 Re: Client SSL validation using root.crt
Previous Message Uwe C. Schroeder 2006-11-21 01:51:25 Re: Postgres misses readline