X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 548D8D1CACE for ; Thu, 29 Jan 2004 16:06:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 92919-02 for ; Thu, 29 Jan 2004 12:06:15 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 55323D1C9CD for ; Thu, 29 Jan 2004 12:06:15 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 540BA3548D; Thu, 29 Jan 2004 08:05:59 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 526D93548C; Thu, 29 Jan 2004 08:05:59 -0800 (PST) Date: Thu, 29 Jan 2004 08:05:59 -0800 (PST) From: Stephan Szabo To: Bruno Wolff III Cc: Achilleus Mantzios , email lists , pgsql-sql@postgresql.org Subject: Re: query not using index for descending records? In-Reply-To: <20040129140655.GA14885@wolff.to> Message-ID: <20040129075643.D23153@megazone.bigpanda.com> References: <20040129131847.GE17068@wolff.to> <20040129140655.GA14885@wolff.to> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/266 X-Sequence-Number: 16659 On Thu, 29 Jan 2004, Bruno Wolff III wrote: > On Thu, Jan 29, 2004 at 15:29:11 +0200, > Achilleus Mantzios wrote: > > O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 : > > > > As i see there was a thread > > http://archives.postgresql.org/pgsql-hackers/2003-05/msg00762.php > > dealing with this issue, assuming the "correct" order by > > should be "order by datetime ASC, id DESC". > > So you really didn't want them in the reverse order? > > > Do you know of any progress for declaring the direction of each > > column in a multicolumn index? > > If you are using 7.4 you can use a functional index to get around this. > Assuming id is a numeric type, you can make an index on datetime and > (-id) and sort by datetime, -id and the index should get used. > > This should still get fixed at some point, as this trick doesn't work > for types for which the - operator exists. But I haven't heard of > anyone working on it for 7.5, so don't expect a real fix any time soon. I'd thought that I'd previously sent a message containing a set of definitions for the reverse opclasses (not meant for inclusion to the system because I was making SQL functions that basically did - to use as the function of the operator class, but possibly worth playing with) but now that I actually search again, I don't see it.