From: | HyunSung Jang <siche(at)siche(dot)net> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org |
Subject: | why my query is not using index?? |
Date: | 2004-10-06 07:31:08 |
Message-ID: | 41639F3C.4050103@siche.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
postgres=# explain ANALYZE select * from test where today < '2004-01-01';
QUERY PLAN
----------------------------------------------------------------------------------------------------
Seq Scan on test (cost=0.00..19.51 rows=334 width=44) (actual
time=0.545..2.429 rows=721 loops=1)
Filter: (today < '2004-01-01 00:00:00'::timestamp without time zone)
Total runtime: 3.072 ms
(3 rows)
postgres=# explain ANALYZE select * from test where today > '2003-01-01'
and today < '2004-01-01';
QUERY
PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using idx_today on test (cost=0.00..18.89 rows=6 width=44)
(actual time=0.055..1.098 rows=365 loops=1)
Index Cond: ((today > '2003-01-01 00:00:00'::timestamp without time
zone) AND (today < '2004-01-01 00:00:00'::timestamp without time zone))
Total runtime: 1.471 ms
(3 rows)
hello
I was expected 1st query should using index, but it doesn't
2nd query doing perfect as you see.
can you explain to me why it's not doing that i expected??
now I'm currently using postgresql 8.0pre3 on linux
/hyunsung jang.
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2004-10-06 07:44:02 | Re: Excessive context switching on SMP Xeons |
Previous Message | Alan Stange | 2004-10-06 03:59:10 | Re: Excessive context switching on SMP Xeons |