Re: Timestamp indexes (why ">" or "between" does not use index?) - Mailing list pgsql-general

From Tom Lane
Subject Re: Timestamp indexes (why ">" or "between" does not use index?)
Date
Msg-id 19464.1203176379@sss.pgh.pa.us
Whole thread Raw
In response to Re: Timestamp indexes (why ">" or "between" does not use index?)  (Michael Glaesemann <grzm@seespotcode.net>)
Responses Re: Timestamp indexes (why ">" or "between" does not use index?)
List pgsql-general
Michael Glaesemann <grzm@seespotcode.net> writes:
> 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?

If you've never analyzed at all, the default assumptions will
discourage the planner from using an indexscan for a one-sided
inequality condition (like "x > constant").  On the other hand,
it usually will use an indexscan for a range inequality (like
"x > constant1 and x < constant2", or a BETWEEN construct).

If you do have ANALYZE stats then it all depends on what fraction of
the column's range is selected by the inequality or range condition.

            regards, tom lane

pgsql-general by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Timestamp indexes (why ">" or "between" does not use index?)
Next
From: Tom Lane
Date:
Subject: Re: SELECT CAST(123 AS char) -> 1