Skip site navigation (1) Skip section navigation (2)

Re: NOW vs CURRENT_DATE

From: Peter Schuller <peter(dot)schuller(at)infidyne(dot)com>
To: dforum <dforums(at)vieonet(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: NOW vs CURRENT_DATE
Date: 2008-08-24 21:22:43
Message-ID: 20080824212243.GA51548@hyperion.scode.org (view raw or flat)
Thread:
Lists: pgsql-performance
> I just discover a big not only big huge difference between NOW() and 
> CURRENT_DATE.
> 
> Did you already know about it and do you know why ?
> 
> DELETE FROM blacklist where bl_date < (NOW() - interval '2 DAY');
> on 6 000 000 of records
> 699 ms
> 
> DELETE FROM blacklist where bl_date < (CURRENT_DATE - interval '2 DAY');
> on 6 000 000 of records

Is this a one-off run after each other (e.g. with a ROLLBACK in
between)? If so I suspect the difference is due to caching and if you
re-run the NOW() version it would also be fast.

Also, NOW() is equivalent to CURRENT_TIMESTAMP() rather than
CURRENT_DATE(). Perhaps the date vs. timestamp has some implication of
how they query is planned.

-- 
/ Peter Schuller

PGP userID: 0xE9758B7D or 'Peter Schuller <peter(dot)schuller(at)infidyne(dot)com>'
Key retrieval: Send an E-Mail to getpgpkey(at)scode(dot)org
E-Mail: peter(dot)schuller(at)infidyne(dot)com Web: http://www.scode.org

In response to

pgsql-performance by date

Next:From: Peter SchullerDate: 2008-08-24 21:29:53
Subject: Re: Large number of tables slow insert
Previous:From: H. HallDate: 2008-08-24 21:01:58
Subject: Re: Large number of tables slow insert

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group