Re: Index on timestamp field, and now()

From: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
To: Denis Perchine <dyp(at)perchine(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Index on timestamp field, and now()
Date: 2002-02-11 15:51:28
Message-ID: 3C67E880.73065EB0@fourpalms.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2002-02-11 15:52:36 Re: [HACKERS] Feature enhancement request : use of libgda in
Previous Message Thomas Lockhart 2002-02-11 15:41:16 Re: timespan_part()?