Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA23204 for ; Sat, 27 Nov 1999 12:19:06 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id MAA18590; Sat, 27 Nov 1999 12:18:02 -0500 (EST) To: Matthias Ackermann cc: pgsql-sql@hub.org Subject: Re: [SQL] Usage of index in "ORDER BY" operations In-reply-to: Your message of Sat, 27 Nov 1999 16:32:15 +0100 <383FF97F.8F408F3B@webcraft.ch> Date: Sat, 27 Nov 1999 12:18:02 -0500 Message-ID: <18588.943723082@sss.pgh.pa.us> From: Tom Lane Matthias Ackermann writes: > So it seems that inserting a WHERE-clause, even if it doesn't do > anything at all (i.e. doesn't reduce the result-set), > is necessary to force the DB to make use of the index. This is true in 6.5: it never even considers an indexscan plan unless there is a WHERE clause that could make use of the index. 7.0 will be smarter. (Current CVS sources already know about making an indexscan plan with no other purpose than to satisfy an ORDER BY; in fact they are probably *too* eager to make use of an index, and will pick that method even when a linear scan and explicit sort would be faster. I need to rejigger the cost estimates to be more realistic, especially by taking LIMIT into account.) regards, tom lane