pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Brian McCane <bmccane@mccons.net>
Cc: pg-admin <pgsql-admin@postgresql.org>
Subject: Re: Useless index
Date: Thu, 14 Feb 2002 11:52:37 -0500 (EST)
Message-ID: <200202141652.g1EGqco05133@candle.pha.pa.us> (raw)
In-Reply-To: <20020214101505.D96354-100000@fw.mccons.net>

Brian McCane wrote:
> On Thu, 14 Feb 2002, 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
> >
> 
> The annoying thing is that it is smart enough to get the correct index, I
> have another index that has the right col1, but different col2.  It seems
> it should be possible to have the optimizer leave col1 in a "high
> impedence" state, and then allow col2 to make a decision.  I have not
> looked at the code, but if we have a known value for col1 as a constant,
> I would think we could let subsequent information make the decision and
> then just bubble it up to the top.

Tom, do we have a TODO item here?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



view thread (11+ messages)  latest in thread

Message-ID: <200202141652.g1EGqco05133@candle.pha.pa.us>
Permalink:  ../200202141652.g1EGqco05133@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200202141652.g1EGqco05133@candle.pha.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: pgman@candle.pha.pa.us, bmccane@mccons.net
  Subject: Re: Useless index
  In-Reply-To: <200202141652.g1EGqco05133@candle.pha.pa.us>
  References: <20020214101505.D96354-100000@fw.mccons.net> <200202141652.g1EGqco05133@candle.pha.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox