Re: [GENERAL] Confusion about composite indexes

2012-05-21 Thread Bill Mitchell
Thanks to everybody's input -- as a first-time poster to this listserv, I wasn't sure how long it would take to get a response. ;) I was frankly astonished to see that the composite index on (a,b) was used when I searched for (a), but Chris' response makes total sense. In this case, I don't want

Re: [GENERAL] Confusion about composite indexes

2012-05-21 Thread Merlin Moncure
On Mon, May 21, 2012 at 3:36 PM, Dmitriy Igrishin wrote: >> So you can get fully index lookups on all of a, b, ab, and ba.  the >> primary key can't optimize ba because indexes only fully match if >> candidate fields are supplied from left to right order.  They can >> still help somewhat, but to a

Re: [GENERAL] Confusion about composite indexes

2012-05-21 Thread Dmitriy Igrishin
2012/5/22 Merlin Moncure > On Mon, May 21, 2012 at 2:34 PM, Bill Mitchell > wrote: > > I am searching for some logic behind the selection of an index in > postgres > > -- it seems that if I have a composite index based on both columns in a > join > > table, it's only referenced if I query on the

Re: [GENERAL] Confusion about composite indexes

2012-05-21 Thread Merlin Moncure
On Mon, May 21, 2012 at 2:34 PM, Bill Mitchell wrote: > I am searching for some logic behind the selection of an index in postgres > -- it seems that if I have a composite index based on both columns in a join > table, it's only referenced if I query on the first term in the composite > index.  I'

Re: [GENERAL] Confusion about composite indexes

2012-05-21 Thread Chris Curvey
On Mon, May 21, 2012 at 3:34 PM, Bill Mitchell wrote: > I am searching for some logic behind the selection of an index in > postgres -- it seems that if I have a composite index based on both columns > in a join table, it's only referenced if I query on the first term in the > composite index.