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 81FE211F6AA0; Wed, 5 Apr 2006 16:14:49 -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 82805-07; Wed, 5 Apr 2006 16:14:48 -0300 (ADT) Received: from hub.org (hub.org [200.46.204.220]) by postgresql.org (Postfix) with ESMTP id 8965A11F6AEB; Wed, 5 Apr 2006 16:14:47 -0300 (ADT) Received: from localhost (av.hub.org [200.46.204.144]) by hub.org (Postfix) with ESMTP id 44AF182457A; Wed, 5 Apr 2006 16:14:44 -0300 (ADT) Received: from hub.org ([200.46.204.220]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92243-05; Wed, 5 Apr 2006 16:14:45 -0300 (ADT) Received: from ganymede.hub.org (blk-222-82-85.eastlink.ca [24.222.82.85]) by hub.org (Postfix) with ESMTP id 3B697824577; Wed, 5 Apr 2006 16:14:42 -0300 (ADT) Received: by ganymede.hub.org (Postfix, from userid 1000) id 9ECD13C952; Wed, 5 Apr 2006 16:14:44 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 9DB4539EB2; Wed, 5 Apr 2006 16:14:44 -0300 (ADT) Date: Wed, 5 Apr 2006 16:14:44 -0300 (ADT) From: "Marc G. Fournier" X-X-Sender: scrappy@ganymede.hub.org To: Tom Lane cc: "Marc G. Fournier" , pgsql-sql@postgresql.org Subject: Re: Reverse Index ... how to ... In-Reply-To: <12527.1144263963@sss.pgh.pa.us> Message-ID: <20060405161430.H947@ganymede.hub.org> References: <20060405151239.F947@ganymede.hub.org> <12527.1144263963@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.611 required=5 tests=[AWL=0.132, DNS_FROM_RFC_ABUSE=0.479] X-Spam-Score: 0.611 X-Spam-Level: X-Archive-Number: 200604/25 X-Sequence-Number: 24834 On Wed, 5 Apr 2006, Tom Lane wrote: > "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) Perfect, that was what I was looking for, thx ... ---- Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664