Re: [GENERAL] pgsql 7.x... - Mailing list pgsql-general

From Howie
Subject Re: [GENERAL] pgsql 7.x...
Date
Msg-id Pine.LNX.3.96.991227092401.1580A-100000@rabies.toodarkpark.org
Whole thread Raw
In response to Re: [GENERAL] pgsql 7.x...  (Mike Mascari <mascarm@mascari.com>)
List pgsql-general
On Sun, 26 Dec 1999, Mike Mascari wrote:

> Howie wrote:
>
> > will this function/index problem be fixed in 7.x ?
> >
> > ircbot=> explain select * from logins where dttime = NOW();
> [SNIP]
> emptoris=> explain select * from sales where saledate = 'now'::datetime;
> NOTICE:  QUERY PLAN:
>
> Index Scan using k_sales4 on sales  (cost=2.80 rows=17 width=140)
>
> EXPLAIN
> emptoris=> explain select * from sales where saledate='now';
> NOTICE:  QUERY PLAN:
>
> Index Scan using k_sales4 on sales  (cost=2.80 rows=17 width=140)
> [SNIP]

not really; just confuses me a bit more.  is 'now()' not the same
datatype as 'now' ?

ircbot=> select now(),'now'::datetime,now()::datetime;
now                   |?column?                    |datetime
----------------------+----------------------------+----------------------------
1999-12-27 04:25:35-05|Mon Dec 27 04:25:35 1999 EST|Mon Dec 27 04:25:35 1999 EST
(1 row)

ircbot=> explain select * from logins where dttime = now()::datetime;
Seq Scan on logins  (cost=33530.89 rows=71043 width=52)

ircbot=> explain select * from logins where dttime = 'now'::datetime;
Index Scan using logins_dttime_idx on logins  (cost=2.54 rows=11 width=52)

ircbot=> select now()::datetime = 'now'::datetime;
?column?
--------
t

isnt 'NOW()' supposed to return a datetime by default?  regardless,
shouldnt 'now()::datetime' be a datetime ?  if so, why isnt my index on
dttime being used when its a direct comparison ?

---
Howie <caffeine@toodarkpark.org>   URL: http://www.toodarkpark.org
"I've learned that you cannot make someone love you.
 All you can do is stalk them and hope they panic and give in."


pgsql-general by date:

Previous
From: franck
Date:
Subject: Re: [GENERAL] Future of PostgreSQL
Next
From: Mike Mascari
Date:
Subject: Re: [GENERAL] pgsql 7.x...