adate::Date is equiv. to adate if adate is type of Date ?
От | Oleg Bartunov |
---|---|
Тема | adate::Date is equiv. to adate if adate is type of Date ? |
Дата | |
Msg-id | Pine.GSO.3.96.SK.990503212440.23733A-100000@ra обсуждение исходный текст |
Список | 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@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83
В списке pgsql-hackers по дате отправления: