Re: Useless index - Mailing list pgsql-admin

From Jean-Luc Lachance
Subject Re: Useless index
Date
Msg-id 3C6BE867.3635E176@nsd.ca
Whole thread Raw
In response to Re: Useless index  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-admin
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 <pgman@candle.pha.pa.us> 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

pgsql-admin by date:

Previous
From: Brian McCane
Date:
Subject: Re: Useless index
Next
From: Bruce Momjian
Date:
Subject: Re: Useless index