indexes with OR clauses is slow ? - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject indexes with OR clauses is slow ?
Date
Msg-id 000c01be71ea$8e662f60$2801007e@cadzone.tpf.co.jp
Whole thread Raw
List pgsql-hackers
Hello all,

While testing Index scan,I found the following phonomenon.SELECT id from xxxxxxwhere id=10 or id=11;

is very fast.

But SELECT id from xxxxxxwhere (id>=10 and id<=10)or (id>=11 and id<=11);

is very slow.
Why ?

The EXPLAIN(not verbose) output of both SQL are same 
except cost and size.
NOTICE:  QUERY PLAN:
Index Scan using xxxxxx_pkey, xxxxxx_pkey on xxxxxx  (cost=1136.17 size=197 width=4)


It seems that (id>=..) is included in indexqual but (id<=.. )
is not.

Thanks.

Hiroshi Inoue
Inoue@tpf.co.jp


pgsql-hackers by date:

Previous
From: Zeugswetter Andreas IZ5
Date:
Subject: AW: [HACKERS] "CANNOT EXTEND" -
Next
From: Ryan Bradetich
Date:
Subject: Re: [Fwd: Re: [HACKERS] Sequences....]