X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id EA90A11F6B02; Wed, 5 Apr 2006 16:06:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63290-02; Wed, 5 Apr 2006 16:06:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- 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 8E27611F6AA7; Wed, 5 Apr 2006 16:06:04 -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 k35J6328012528; Wed, 5 Apr 2006 15:06:03 -0400 (EDT) To: "Marc G. Fournier" cc: pgsql-sql@postgresql.org Subject: Re: Reverse Index ... how to ... In-reply-to: <20060405151239.F947@ganymede.hub.org> References: <20060405151239.F947@ganymede.hub.org> Comments: In-reply-to "Marc G. Fournier" message dated "Wed, 05 Apr 2006 15:14:42 -0300" Date: Wed, 05 Apr 2006 15:06:03 -0400 Message-ID: <12527.1144263963@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.114 required=5 tests=[AWL=0.114] X-Spam-Score: 0.114 X-Spam-Level: X-Archive-Number: 200604/24 X-Sequence-Number: 24833 "Marc G. Fournier" writes: > I'm still searching through Google and whatnot, but not finding anything > off the bat ... is there some way of creating a 'REVERSE INDEX' on a > column in a table? > For instance, when I do a 'CLUSTER' to sort a table based on an INDEX, I'd > like to sort it in reverse order, so would need the INDEX to go from > 'GREATEST to LOWEST', vs 'LOWEST to GREATEST' ... You shouldn't need to worry about that during CLUSTER, as the system is perfectly capable of scanning an index in either forward or backward order at runtime. For example, regression=# explain select * from tenk1 order by unique1; QUERY PLAN ------------------------------------------------------------------------------------ Index Scan using tenk1_unique1 on tenk1 (cost=0.00..1572.00 rows=10000 width=244) (1 row) regression=# explain select * from tenk1 order by unique1 desc; QUERY PLAN --------------------------------------------------------------------------------------------- Index Scan Backward using tenk1_unique1 on tenk1 (cost=0.00..1572.00 rows=10000 width=244) (1 row) regards, tom lane