Compund indexes and ORs

Поиск
Список
Период
Сортировка
От Dmitry Tkach
Тема Compund indexes and ORs
Дата
Msg-id 3EE12418.1030202@openratings.com
обсуждение исходный текст
Ответы Re: Compund indexes and ORs  (Peter Eisentraut <peter_e@gmx.net>)
Re: Compund indexes and ORs  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От:
Дата:
Сообщение: Approved
Следующее
От: Achilleus Mantzios
Дата:
Сообщение: Re: Installation problems