From: | Denis Perchine <dyp(at)perchine(dot)com> |
---|---|
To: | lockhart(at)fourpalms(dot)org |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Index on timestamp field, and now() |
Date: | 2002-02-11 16:09:06 |
Message-ID: | 20020211124610.30AF01FE0C@mx.webmailstation.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
> > 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.
Oops. Sorry. 7.2.
> Use the constant "timestamp 'now'" instead; seems to work for me in
> PgSQL 7.1.
No luck.
webmailstation=> explain select * from queue where send_date > timestamp
'now';
NOTICE: QUERY PLAN:
Seq Scan on queue (cost=0.00..10114.06 rows=80834 width=190)
EXPLAIN
Although exact search uses index scan:
webmailstation=> explain select * from queue where send_date = timestamp
'now';
NOTICE: QUERY PLAN:
Index Scan using queue_senddate_key on queue (cost=0.00..5.95 rows=1
width=190)
EXPLAIN
--
Denis
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-02-11 16:15:09 | Re: pg_hba.conf problem? |
Previous Message | Andrew Sullivan | 2002-02-11 15:52:36 | Re: [HACKERS] Feature enhancement request : use of libgda in |