Re: Compund indexes and ORs

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Compund indexes and ORs
Date: 2003-06-07 16:02:01
Message-ID: Pine.LNX.4.44.0306071623080.2132-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2003-06-07 16:31:20 Re: [BUGS] Detecting proper bison version before make
Previous Message Tom Lane 2003-06-07 15:44:25 Re: [BUGS] Detecting proper bison version before make