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

From Tom Lane
Subject Re: Index on timestamp field, and now()
Date
Msg-id 21253.1013525316@sss.pgh.pa.us
Whole thread Raw
In response to Re: Index on timestamp field, and now()  (Denis Perchine <dyp@perchine.com>)
Responses Re: Index on timestamp field, and now()
List pgsql-general
Denis Perchine <dyp@perchine.com> writes:
> 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
>
>  queue     | send_date  |         0 |         8 |         -1 |




>                                                                   |
>                                                                      |
> {"2001-12-27 21:58:24-05","2002-02-12 08:48:18.967111-05","2002-02-12
> 15:14:51.89063-05","2002-02-13 04:06:19.979181-05","2002-02-13
> 16:20:37.753221-05","2002-02-14 12:03:09.714262-05","2002-02-15
> 15:15:58.04151-05","2002-02-17 11:06:16.964311-05","2002-02-20
> 08:40:57.795043-05","2002-03-12 07:25:46-05","2003-10-28 14:58:58-05"}
>                              |   -0.359735

According to this histogram, 90% of your table has send_date in the
future.  Accordingly, seqscan is the right plan for the above query.

            regards, tom lane

pgsql-general by date:

Previous
From: Darren Ferguson
Date:
Subject: Re: index use again and again
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Feature enhancement request : use of libgda in