Re: Index on timestamp field, and now() - Mailing list pgsql-general

From Thomas Lockhart
Subject Re: Index on timestamp field, and now()
Date
Msg-id 3C67E880.73065EB0@fourpalms.org
Whole thread Raw
In response to Index on timestamp field, and now()  (Denis Perchine <dyp@perchine.com>)
Responses Re: Index on timestamp field, and now()
List pgsql-general
> I have quite interesting problem. I have a table with a timestamp field.
> I have an index on it. When I use constant date in where clause, PostgreSQL
> uses index. But when I try to use now() there, it uses a sequence scan.
> As far as I can understand in inside any query now() is a constant.
> What is the problem here.

You did not specify what version of PostgreSQL you are running, but it
may be that now() is returning abstime, not timestamp.

Use the constant "timestamp 'now'" instead; seems to work for me in
PgSQL 7.1.

                    - Thomas

pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: [HACKERS] Feature enhancement request : use of libgda in
Next
From: Denis Perchine
Date:
Subject: Re: Index on timestamp field, and now()