Re: Timestamp-based indexing

From: Kevin Barnard <kbarnard(at)speedfc(dot)com>
To: "Harmon S(dot) Nine" <hnine(at)netarx(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Timestamp-based indexing
Date: 2004-07-26 14:58:38
Message-ID: 41051C1E.90805@speedfc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Harmon S. Nine wrote:

> monitor=# explain analyze select * from "eventtable" where timestamp >
> CURRENT_TIMESTAMP - INTERVAL '10 minutes';
> QUERY PLAN

Try

SELECT * FROM eventtable where timestamp BETWEEN (CURRENT_TIMESTAMP -
INTERVAL '10 minutes') AND CURRENT_TIMESTAMP;

This should will use a range off valid times. What your query is doing
is looking for 10 minutes ago to an infinate future. Statically
speaking that should encompass most of the table because you have an
infinate range. No index will be used. If you assign a range the
planner can fiqure out what you are looking for.

--
Kevin Barnard
Speed Fulfillment and Call Center
kbarnard(at)speedfc(dot)com
214-258-0120

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Matthew T. O'Connor 2004-07-26 15:09:53 Re: Timestamp-based indexing
Previous Message Merlin Moncure 2004-07-26 14:56:54 Re: arrays and indexes