indexes with OR clauses is slow ?

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "pgsql-hackers" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: indexes with OR clauses is slow ?
Date: 1999-03-19 09:26:23
Message-ID: 000c01be71ea$8e662f60$2801007e@cadzone.tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello all,

While testing Index scan,I found the following phonomenon.

SELECT id from xxxxxx
where id=10 or id=11;

is very fast.

But
SELECT id from xxxxxx
where (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(at)tpf(dot)co(dot)jp

Browse pgsql-hackers by date

  From Date Subject
Next Message Ryan Bradetich 1999-03-19 09:27:46 Re: [Fwd: Re: [HACKERS] Sequences....]
Previous Message Zeugswetter Andreas IZ5 1999-03-19 08:13:45 AW: [HACKERS] "CANNOT EXTEND" -