Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1EG5tE01601 for ; Thu, 14 Feb 2002 11:05:55 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g1EG5qf09038; Thu, 14 Feb 2002 11:05:52 -0500 (EST) To: Bruce Momjian cc: Brian McCane , pg-admin Subject: Re: Useless index In-reply-to: <200202141542.g1EFgSV28050@candle.pha.pa.us> References: <200202141542.g1EFgSV28050@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Thu, 14 Feb 2002 10:42:28 -0500" Date: Thu, 14 Feb 2002 11:05:51 -0500 Message-ID: <9035.1013702751@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200202/179 X-Sequence-Number: 3335 Bruce Momjian writes: > In fact, I am unsure why you are specifying the primary column in the > ORDER BY anyway if you know it will be a single value, except perhaps to > try and get it to use the index, right? Exactly. The sort ordering of the index is (col1,col2) while the query as originally written wanted an ordering of (col2 desc). The planner's not smart enough to realize that since the WHERE constrains col1 to a single value, you could pretend the query requests an ordering of (col1 desc, col2 desc) which is compatible with the index. regards, tom lane