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 986DDD1B466 for ; Thu, 29 Jan 2004 15:04:51 +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 62764-06 for ; Thu, 29 Jan 2004 11:04:29 -0400 (AST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id B5EAFD1D262 for ; Thu, 29 Jan 2004 11:04:17 -0400 (AST) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id i0TF1iSD010145; Thu, 29 Jan 2004 17:01:44 +0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id i0TF1h6g010141; Thu, 29 Jan 2004 17:01:44 +0200 Date: Thu, 29 Jan 2004 17:01:43 +0200 (EET) From: Achilleus Mantzios To: Bruno Wolff III Cc: email lists , Subject: Re: query not using index for descending records? In-Reply-To: <20040129140655.GA14885@wolff.to> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/262 X-Sequence-Number: 16655 O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 : > 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? I am not the initiator of this thread, i was just lurking :) > > > 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. > It would be nice to have this feature for varchar as well. > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > -- -Achilleus