From: Peter Schuller <peter.schuller@infidyne.com>
To: dforum <dforums@vieonet.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: NOW vs CURRENT_DATE
Date: Sun, 24 Aug 2008 23:22:43 +0200
Message-ID: <20080824212243.GA51548@hyperion.scode.org> (raw)
In-Reply-To: <48B1BE33.3060505@vieonet.com>
References: <48B1BE33.3060505@vieonet.com>
> 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.schuller@infidyne.com>'
Key retrieval: Send an E-Mail to getpgpkey@scode.org
E-Mail: peter.schuller@infidyne.com Web: http://www.scode.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: peter.schuller@infidyne.com, dforums@vieonet.com
Subject: Re: NOW vs CURRENT_DATE
In-Reply-To: <20080824212243.GA51548@hyperion.scode.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox