Received: from beamish.nsd.ca ([205.150.156.194]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1EGVnE09431 for ; Thu, 14 Feb 2002 11:31:50 -0500 (EST) (envelope-from jllachan@nsd.ca) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id LAA30279; Thu, 14 Feb 2002 11:31:53 -0500 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma030275; Thu, 14 Feb 02 11:31:33 -0500 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id LAA23989; Thu, 14 Feb 2002 11:32:19 -0500 Message-ID: <3C6BE867.3635E176@nsd.ca> Date: Thu, 14 Feb 2002 11:40:07 -0500 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-12 i686) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane CC: pg-admin Subject: Re: Useless index References: <200202141542.g1EFgSV28050@candle.pha.pa.us> <9035.1013702751@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200202/181 X-Sequence-Number: 3337 Here is another peeve Having to specify the type of a constant in a SELECT DISTINCT 'foo'... I which I had more spare time to contribute... Jean-Luc Tom Lane wrote: > > 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 > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster