X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id B9ED111F6796 for ; Tue, 18 Apr 2006 20:08:42 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -2.306 X-Spam-Level: X-Spam-Status: No, score=-2.306 required=5 tests=[AWL=0.295, BAYES_00=-2.599, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id c45chBJiEecW for ; Tue, 18 Apr 2006 20:08:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id E557511F65E7 for ; Tue, 18 Apr 2006 20:08:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k3IN8Xcm019820; Tue, 18 Apr 2006 19:08:33 -0400 (EDT) To: theo@flame.co.za cc: pgsql-performance@postgresql.org Subject: Re: Multicolumn order by In-reply-to: <1145398075.3048.18.camel@josh> References: <1145398075.3048.18.camel@josh> Comments: In-reply-to Theo Kramer message dated "Wed, 19 Apr 2006 00:07:55 +0200" Date: Tue, 18 Apr 2006 19:08:33 -0400 Message-ID: <19819.1145401713@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200604/406 X-Sequence-Number: 18490 Theo Kramer writes: > select * from mytable where > (c1 = 'c1v' and c2 = 'c2v' and c3 >= 'c3v') or > (c1 = 'c1v' and c2 > 'c2v') or > (c1 > 'c1v') > order by c1, c2, c3; Yeah ... what you really want is the SQL-spec row comparison operator select ... where (c1,c2,c3) >= ('c1v','c2v','c3v') order by c1,c2,c3; This does not work properly in any current PG release :-( but it does work and is optimized well in CVS HEAD. See eg this thread http://archives.postgresql.org/pgsql-hackers/2006-02/msg00209.php regards, tom lane