Re: Indexing timestamp columns - Mailing list pgsql-general

From Tom Lane
Subject Re: Indexing timestamp columns
Date
Msg-id 24085.1049134173@sss.pgh.pa.us
Whole thread Raw
In response to Indexing timestamp columns  (Pedro Alves <pmalves@think.pt>)
List pgsql-general
Pedro Alves <pmalves@think.pt> writes:
>   Is it possible to make a timestamp column use a index in a query like
> select foo from bar where timestamp <= smth?

The planner will do that if it thinks it's appropriate --- which in most
cases it won't.  Unless your limit is pretty close to the oldest
timestamp in the table, this query will be quite unselective and so a
seqscan is actually the better way to do it.

If you want to find out whether the planner guessed right, try forcing
it to use an indexscan (via "set enable_seqscan = off").  Compare
timings.

            regards, tom lane


pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: Re: plpgsql question
Next
From: "Andy Kriger"
Date:
Subject: dump a single record as sql?