Re: Useless index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Brian McCane <bmccane(at)mccons(dot)net>, pg-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Useless index
Date: 2002-02-14 16:05:51
Message-ID: 9035.1013702751@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Brian McCane 2002-02-14 16:19:22 Re: Useless index
Previous Message Bruce Momjian 2002-02-14 15:42:28 Re: Useless index