X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 779BF11F6006 for ; Tue, 11 Apr 2006 14:59:37 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.12 X-Spam-Level: X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id vBky-b1sBTaF for ; Tue, 11 Apr 2006 14:59:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 7FA3411F6717 for ; Tue, 11 Apr 2006 14:59:29 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (Tb349.t.pppool.de [89.55.179.73]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 17AD1656CB for ; Tue, 11 Apr 2006 20:00:20 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id C170B181520C4 for ; Tue, 11 Apr 2006 19:59:39 +0200 (CEST) Message-ID: <443BEE8B.4030301@logix-tt.com> Date: Tue, 11 Apr 2006 19:59:39 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Indexes with descending date columns References: <200604090326.k393Qpm08170@candle.pha.pa.us> In-Reply-To: <200604090326.k393Qpm08170@candle.pha.pa.us> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Archive-Number: 200604/239 X-Sequence-Number: 18323 Hi, Bruce, Bruce Momjian wrote: >>Ahh. There's a hack to do that by defining a new opclass that reverses < >>and >, and then doing ORDER BY project_id, id, date USING new_opclass. >> >>I think there's a TODO about this, but I'm not sure... > > Yes, and updated: > > * Allow the creation of indexes with mixed ascending/descending > specifiers > > This is possible now by creating an operator class with reversed sort > operators. One complexity is that NULLs would then appear at the start > of the result set, and this might affect certain sort types, like > merge join. I think it would be better to allow "index zig-zag scans" for multi-column index.[1] So it traverses in a given order on the higher order column, and the sub trees for each specific high order value is traversed in reversed order. From my knowledge at least of BTrees, and given correct commutator definitions, this should be not so complicated to implement.[2] This would allow the query planner to use the same index for arbitrary ASC/DESC combinations of the given columns. Just a thought, Markus [1] It may make sense to implement the mixed specifiers on indices as well, to allow CLUSTERing on mixed search order. [2] But I admit that I currently don't have enough knowledge in PostgreSQL index scan internals to know whether it really is easy to implement. -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org