Re: Timestamp-based indexing - Mailing list pgsql-performance

From Kevin Barnard
Subject Re: Timestamp-based indexing
Date
Msg-id 41051C1E.90805@speedfc.com
Whole thread Raw
In response to Timestamp-based indexing  ("Harmon S. Nine" <hnine@netarx.com>)
Responses Re: Timestamp-based indexing
List 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@speedfc.com
214-258-0120


pgsql-performance by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: arrays and indexes
Next
From: "Matthew T. O'Connor"
Date:
Subject: Re: Timestamp-based indexing