From: | list-pgsql-general(at)news(dot)cistron(dot)nl ("Miquel van Smoorenburg" ) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | index not always used when selecting on a date field |
Date: | 2004-11-07 20:56:05 |
Message-ID: | cmm254$t5d$1@news.cistron.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have a database with a btree index on the 'removed' field,
which is of type 'date'. However it isn't being used:
techdb2=> explain select * from lines where removed > CURRENT_DATE;
QUERY PLAN
------------------------------------------------------------
Seq Scan on lines (cost=0.00..243.47 rows=2189 width=324)
Filter: (removed > ('now'::text)::date)
(2 rows)
Now the weird thing is that if I select a range it is being used:
techdb2=> explain select * from lines where removed > CURRENT_DATE and removed < '9999-01-01';
QUERY PLAN
------------------------------------------------------------------------------------
Index Scan using lines_removed_idx on lines (cost=0.00..120.56 rows=33 width=324)
Index Cond: ((removed > ('now'::text)::date) AND (removed < '9999-01-01'::date))
(2 rows)
Why is this?
(Tested with both 7.3.2 and 7.4.6)
Mike.
From | Date | Subject | |
---|---|---|---|
Next Message | Ned Lilly | 2004-11-07 21:06:54 | Re: Report Generation |
Previous Message | Grant McLean | 2004-11-07 20:55:01 | Re: Visual Designer in linux? |