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