Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E355C650171 for ; Sun, 24 Aug 2008 18:22:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 07872-07 for ; Sun, 24 Aug 2008 18:22:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from hyperion.scode.org (hyperion.scode.org [85.17.42.115]) by postgresql.org (Postfix) with ESMTP id BC7D6650164 for ; Sun, 24 Aug 2008 18:22:48 -0300 (ADT) Received: by hyperion.scode.org (Postfix, from userid 1001) id 0849123C46A; Sun, 24 Aug 2008 23:22:43 +0200 (CEST) Date: Sun, 24 Aug 2008 23:22:43 +0200 From: Peter Schuller To: dforum Cc: pgsql-performance@postgresql.org Subject: Re: NOW vs CURRENT_DATE Message-ID: <20080824212243.GA51548@hyperion.scode.org> References: <48B1BE33.3060505@vieonet.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline In-Reply-To: <48B1BE33.3060505@vieonet.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/310 X-Sequence-Number: 31191 --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > I just discover a big not only big huge difference between NOW() and=20 > CURRENT_DATE. >=20 > Did you already know about it and do you know why ? >=20 > DELETE FROM blacklist where bl_date < (NOW() - interval '2 DAY'); > on 6 000 000 of records > 699 ms >=20 > 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. --=20 / Peter Schuller PGP userID: 0xE9758B7D or 'Peter Schuller ' Key retrieval: Send an E-Mail to getpgpkey@scode.org E-Mail: peter.schuller@infidyne.com Web: http://www.scode.org --/04w6evG8XlLl3ft Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkix0SMACgkQDNor2+l1i32T/ACgk/yxH+BRMhI2CYIK7B/P4Coj TjwAoJpY3tvtlW8W7MQZIMrUkfWEyVo1 =PsRZ -----END PGP SIGNATURE----- --/04w6evG8XlLl3ft--