'now' runtime

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: List pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: 'now' runtime
Date: 2005-04-07 11:13:04
Message-ID: 1112872384.3834.161.camel@petra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


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(at)zf(dot)jcu(dot)cz>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2005-04-07 12:11:26 Re: Shared row locking, revisited
Previous Message Palle Girgensohn 2005-04-07 08:25:42 Re: prepared statements don't log arguments?