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 68EFFD1BB52 for ; Thu, 29 Jan 2004 14:06:01 +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 38629-09 for ; Thu, 29 Jan 2004 10:05:38 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 36E76D1D179 for ; Thu, 29 Jan 2004 10:05:29 -0400 (AST) Received: (qmail 19032 invoked by uid 500); 29 Jan 2004 14:06:55 -0000 Date: Thu, 29 Jan 2004 08:06:55 -0600 From: Bruno Wolff III To: Achilleus Mantzios Cc: email lists , pgsql-sql@postgresql.org Subject: Re: query not using index for descending records? Message-ID: <20040129140655.GA14885@wolff.to> Mail-Followup-To: Achilleus Mantzios , email lists , pgsql-sql@postgresql.org References: <20040129131847.GE17068@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/259 X-Sequence-Number: 16652 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.