From: | Oleg Bartunov <oleg(at)sai(dot)msu(dot)su> |
---|---|
To: | pgsql-hackers(at)hub(dot)org |
Subject: | adate::Date is equiv. to adate if adate is type of Date ? |
Date: | 1999-05-03 17:35:55 |
Message-ID: | Pine.GSO.3.96.SK.990503212440.23733A-100000@ra |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Here is a problem I got while experiencing with date type:
when I use adate = 'today'::Date explain shows me postgres will use
index, but adate::Date = 'today'::Date (which is the same expression )doesn't
use index. This happens for 6.4.2 and 6.5 cvs.
Regards,
Oleg
PS.
btw, how I can find 'something' older than a month, i.e.
select * from titles where adate::date > 'today'::Date - '1 month'::timespan;
apod=> vacuum analyze;
VACUUM
apod=> explain select count(*) from titles where adate::Date = 'today'::Date;
NOTICE: QUERY PLAN:
Aggregate (cost=64.10 size=0 width=0)
-> Seq Scan on titles (cost=64.10 size=699 width=12)
EXPLAIN
apod=> explain select count(*) from titles where adate = 'today'::Date;
NOTICE: QUERY PLAN:
Aggregate (cost=2.04 size=0 width=0)
-> Index Scan using idx_adate on titles (cost=2.04 size=1 width=12)
EXPLAIN
apod=> select version();
version
------------------------------------------------------------------
PostgreSQL 6.4.2 on i586-pc-linux-gnu, compiled by gcc egcs-2.91.5
(1 row)
apod=> \d titles
Table = titles
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| url | char() | 13 |
| adate | date | 4 |
| atitle | text | var |
+----------------------------------+----------------------------------+-------+
Indices: idx_adate
idx_atitle
idx_url
a
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
From | Date | Subject | |
---|---|---|---|
Next Message | Michael J Davis | 1999-05-03 17:57:01 | RE: [HACKERS] GROUP BY fixes committed |
Previous Message | Thomas Lockhart | 1999-05-03 17:23:06 | Re: [HACKERS] GROUP BY fixes committed |