current_date vs 'now' - Mailing list pgsql-sql

From Jamie Tufnell
Subject current_date vs 'now'
Date
Msg-id b0a4f3350902042205l6ba4f2c0u2545992fbb7e9088@mail.gmail.com
Whole thread Raw
Responses Re: current_date vs 'now'
List pgsql-sql
Hi,

I was doing EXPLAIN ANALYZE on a query where I compare against
current_date and noticed the following:
  Filter: (date <= ('now'::text)::date)

I knew about now() but did not know about 'now' and have since learnt
of 'today', 'tomorrow', etc.  Great!

So, I changed my condition to <= 'now' to see if there would be any
improvement, which changed the filter line to:
  Filter: (date <= '2009-02-05'::date)

and without fail this query is 2ms quicker every time.  I alternated
between the two and ran them both several times to make sure it wasn't
just a cache difference.

AFAIK current_date is standard and 'now' and 'today', etc are not...
so that's one reason to continuing using current_date.  However, I
wonder why 'today' and current_date don't generate the same query
plan?

Jamie


pgsql-sql by date:

Previous
From: Chris
Date:
Subject: Re: postgre2postgre
Next
From: Tom Lane
Date:
Subject: Re: current_date vs 'now'