Unix Technical Forum

'now' runtime

This is a discussion on 'now' runtime within the pgsql Hackers forums, part of the PostgreSQL category; --> Why is there so different "Total runtime" for ('now'::text)::date) and '2005-04-06'::date ? I think both is constant during execution. ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 04:21 AM
Karel Zak
 
Posts: n/a
Default 'now' runtime


Why is there so different "Total runtime" for ('now'::text)::date) and
'2005-04-06'::date ?

I think both is constant during execution.


CREATE TABLE test (
_time timestamp with time zone,
_platform character(5),
_tld character(5)
) WITHOUT OIDS;


explain analyze SELECT count(*) from test where
_time::date=CURRENT_DATE;
QUERY PLAN
----------------------------------------------------------------------------------------------------
Aggregate (cost=0.01..0.01 rows=1 width=0) (actual time=0.026..0.029
rows=1 loops=1)
-> Seq Scan on test (cost=0.00..0.00 rows=1 width=0) (actual
time=0.004..0.004 rows=0 loops=1)
Filter: ((_time)::date = ('now'::text)::date)
Total runtime: 24.034 ms
^^^^^^^^


explain analyze SELECT count(*) from test where
_time::date='2005-04-06'::date;
QUERY PLAN
----------------------------------------------------------------------------------------------------
Aggregate (cost=0.01..0.01 rows=1 width=0) (actual time=0.015..0.018
rows=1 loops=1)
-> Seq Scan on test (cost=0.00..0.00 rows=1 width=0) (actual
time=0.004..0.004 rows=0 loops=1)
Filter: ((_time)::date = '2005-04-06'::date)
Total runtime: 0.065 ms
^^^^^^^^

Karel

--
Karel Zak <zakkr@zf.jcu.cz>


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 04:21 AM
Tom Lane
 
Posts: n/a
Default Re: 'now' runtime

Karel Zak <zakkr@zf.jcu.cz> writes:
> Why is there so different "Total runtime" for ('now'::text)::date) and
> '2005-04-06'::date ?


> I think both is constant during execution.


Not at all. text_date() is not immutable so it has to be applied during
execution. The other one is just a constant.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:07 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com