Re: Compund indexes and ORs - Mailing list pgsql-bugs

From Peter Eisentraut
Subject Re: Compund indexes and ORs
Date
Msg-id Pine.LNX.4.44.0306071623080.2132-100000@peter.localdomain
Whole thread Raw
In response to Compund indexes and ORs  (Dmitry Tkach <dmitry@openratings.com>)
List pgsql-bugs
Dmitry Tkach writes:

> explain select * from abc where a=1 and b in (1,2);
>
>                              QUERY PLAN
> ---------------------------------------------------------------------
>  Index Scan using abc_idx on abc  (cost=0.00..17.09 rows=1 width=12)
>    Index Cond: (a = 1)
>    Filter: ((b = 1) OR (b = 2))
>
>
> Now, why  doesn't it want to use the index for the second condition???

It can only use all columns of a multicolumn index if the columns are used
in clauses connected by OR.  This is described in the documentation.

--
Peter Eisentraut   peter_e@gmx.net

pgsql-bugs by date:

Previous
From: Dima Tkach
Date:
Subject: Re: Compund indexes and ORs
Next
From: Tom Lane
Date:
Subject: Re: Compund indexes and ORs