Re: Composite index planner issues Was: Re: Constraint exclusion oddity with composite index

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Composite index planner issues Was: Re: Constraint exclusion oddity with composite index
Date: 2007-06-07 00:01:33
Message-ID: 46674ADD.2060904@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
>>> I guess where I got confused is:
>>>
>>> http://www.postgresql.org/docs/8.1/static/indexes-multicolumn.html
>>>
>>> And explicitly:
>>>
>>> A multicolumn B-tree index can be used with query conditions that
>>> involve any subset of the index's columns, but the index is most
>>> efficient when there are constraints on the leading (leftmost) columns.
>
>> Considering the paragraph from the documentation above, should we change
>> the documentation?
>
> That statement seems perfectly accurate to me.

O.k. then perhaps I am being dense, but that statement says to me that
the planner should be able to use the right element of a composite index
but that it will not always do so.

Considering an index of a,b if I search for b I would expect that the
planner could use the index. Assuming of course that the planner would
use the same index if it was just b.

Further, I would expect a smaller chance of it using b if the index was
a,c,b but that it "might" still use it.

Is that not the case? Should I expect that even in the simplest of cases
that we will not use an index unless it is *the* leftmost element?

Sincerely,

Joshua D. Drake

>
> regards, tom lane
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-06-07 00:26:07 Re: Composite index planner issues Was: Re: Constraint exclusion oddity with composite index
Previous Message Tom Lane 2007-06-06 23:47:45 Re: Composite index planner issues Was: Re: Constraint exclusion oddity with composite index