Compund indexes and ORs - Mailing list pgsql-bugs

From Dmitry Tkach
Subject Compund indexes and ORs
Date
Msg-id 3EE12418.1030202@openratings.com
Whole thread Raw
Responses Re: Compund indexes and ORs  (Peter Eisentraut <peter_e@gmx.net>)
Re: Compund indexes and ORs  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Here is a trouble I am having, that looks like a bug to me:

create table abc (a int, b int, c int);
create index abc_idx on abc (a,b,c);
set enable_seqscan=off;

explain select * from abc where a in (1,2,3);

                                     QUERY
PLAN
------------------------------------------------------------------------
-------
 Index Scan using abc_idx, abc_idx on abc  (cost=0.00..34.16 rows=10
width=12)
   Index Cond: ((a = 1) OR (a = 2))
(2 rows)

Looks great - just what I expect,  *but*:

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???
Any ideas?

Thanks a lot!

Dima

pgsql-bugs by date:

Previous
From:
Date:
Subject: Approved
Next
From: Achilleus Mantzios
Date:
Subject: Re: Installation problems