Re: Timestamp indexes (why ">" or "between" does not use index?)

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: "Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com>
Cc: "PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Timestamp indexes (why ">" or "between" does not use index?)
Date: 2008-02-16 15:11:41
Message-ID: AFCE3873-698E-48D2-A721-0EC219A2E2D2@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Feb 16, 2008, at 9:42 , Phoenix Kiula wrote:

> The EXPLAIN tells me it needs to do a seq
> scan. Why is this? How can I make a date/time field index which uses
> both equality criteria and the greater than/lesser than/between
> criteria?
>

The planner will choose a seq scan if it thinks that it will be
faster than using an index: if based on its statistics it thinks a
large portion of rows will match the criteria, a seq scan may well be
faster than an index scan.

Have you analyzed recently? Showing us the EXPLAIN ANALYZE for your
query would be helpful. Have you tried running the EXPLAIN ANALYZE
with seq scans disabled?

Michael Glaesemann
grzm seespotcode net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arturo Pérez 2008-02-16 15:38:56 nntp interface not working?
Previous Message Phoenix Kiula 2008-02-16 15:07:16 Re: Timestamp indexes (why ">" or "between" does not use index?)