Re: Index on timestamp field, and now()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Denis Perchine <dyp(at)perchine(dot)com>
Cc: lockhart(at)fourpalms(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Index on timestamp field, and now()
Date: 2002-02-12 14:48:36
Message-ID: 21253.1013525316@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Denis Perchine <dyp(at)perchine(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-02-12 14:57:56 Re: [HACKERS] Feature enhancement request : use of libgda in
Previous Message Darren Ferguson 2002-02-12 14:24:24 Re: index use again and again