Received: from localhost (pluto.hub.org [200.46.204.4]) by postgresql.org (Postfix) with ESMTP id 6C7F09F9EEC for ; Tue, 21 Nov 2006 01:56:17 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.4]) (amavisd-new, port 10024) with ESMTP id 77994-02-3 for ; Tue, 21 Nov 2006 01:56:10 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by postgresql.org (Postfix) with ESMTP id E41B69FA344 for ; Tue, 21 Nov 2006 01:02:42 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so1184598ugf for ; Mon, 20 Nov 2006 21:02:41 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=ENAzA24C+X6g6lBdIcZFwNgNF1OQ+PgeVo89pneAm7+UlZ/CD7uy0u5d3s9mr52plg7yWLzusy9g8nLm+xCwzQKTtlUw52uxg9WZegvG4A4yND5sR9smBgW4BKe+uL71HvnmbXQA5FXrq6uKkqTXrd45cUv3kS2Zf/JdWCJDG5U= Received: by 10.67.22.7 with SMTP id z7mr66686ugi.1164078334214; Mon, 20 Nov 2006 19:05:34 -0800 (PST) Received: by 10.66.240.18 with HTTP; Mon, 20 Nov 2006 19:05:34 -0800 (PST) Message-ID: <65937bea0611201905v3f5adf02r254d82cc6d26f641@mail.gmail.com> Date: Tue, 21 Nov 2006 08:35:34 +0530 From: "Gurjeet Singh" To: "Harald Fuchs" Subject: Re: ORDER BY Cc: pgsql-general@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_49170_23138880.1164078334104" References: <1163541820.580520.110310@k70g2000cwa.googlegroups.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/1155 X-Sequence-Number: 104251 ------=_Part_49170_23138880.1164078334104 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 16 Nov 2006 11:04:15 +0100, Harald Fuchs 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[.singh]@EnterpriseDB.com singh.gurjeet@{ gmail | hotmail | yahoo }.com ------=_Part_49170_23138880.1164078334104 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 16 Nov 2006 11:04:15 +0100, Harald Fuchs <hf1110x@protecting.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[.singh]@EnterpriseDB.com
singh.gurjeet@{ gmail | hotmail | yahoo }.com ------=_Part_49170_23138880.1164078334104--