Re: Constraint exclusion oddity with composite index - Mailing list pgsql-hackers

From Joshua D. Drake
Subject Re: Constraint exclusion oddity with composite index
Date
Msg-id 466095CA.9040205@commandprompt.com
Whole thread Raw
In response to Re: Constraint exclusion oddity with composite index  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Composite index planner issues Was: Re: Constraint exclusion oddity with composite index  ("Joshua D. Drake" <jd@commandprompt.com>)
List pgsql-hackers
Tom Lane wrote:
> "Joshua D. Drake" <jd@commandprompt.com> writes:
>> Tom Lane wrote:
>>> "Joshua D. Drake" <jd@commandprompt.com> writes:
>>>> Assume the following:
>>>> index on: (id, adate)
>>>> constraint CHECK(adate > '01-01-2007' AND adate < '04-01-2007');
>>>> The planner will not use the index listed above.
>>> For what?
> 
>> select adate from parent where adate = '01-25-2007'
> 
> That's unsurprising.  Searching with only a lower-order index column
> value seldom wins, 'cause you've got to scan the entire index.  The
> constraint is irrelevant to this.

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.

Sincerely,

Joshua D. Drake


> 
>             regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
> 


-- 
      === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive  PostgreSQL solutions since 1997             http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/



pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: syslogger line-end processing infelicity
Next
From: Andrew Dunstan
Date:
Subject: Re: syslogger line-end processing infelicity