Understanding sequential versus index scans. - Mailing list pgsql-general

From Robert James
Subject Understanding sequential versus index scans.
Date
Msg-id e09785e00907191558q4da127f1k46d6c59575503a5c@mail.gmail.com
Whole thread Raw
Responses Re: Understanding sequential versus index scans.
Re: Understanding sequential versus index scans.
Re: Understanding sequential versus index scans.
List pgsql-general
Hi.  I notice that when I do a WHERE x, Postgres uses an index, and when I do WHERE y, it does so as well, but when I do WHERE x OR y, it doesn't.  Why is this so? And how can I shut this off?
select * from dict
where 
 word in (select substr('moon', 0, generate_series(3,length('moon')))) -- this is my X above
 OR word like 'moon%' -- this is my Y above

Seq Scan on dict (cost=0.02..2775.66 rows=30422 width=24) (actual time=16.635..28.580 rows=8 loops=1)
 Filter: ((hashed subplan) OR ((word)::text ~~ 'moon%'::text))
 SubPlan
 -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.014..0.019 rows=2 loops=1)
Total runtime: 28.658 ms
(Using just X or Y alone uses the index, and completes in 0.150 ms)
Is this a bug?




pgsql-general by date:

Previous
From: Konstantin Pavlov
Date:
Subject: Full text search in PostgreSQL 8.4
Next
From: Robert James
Date:
Subject: Re: Understanding sequential versus index scans.