Indexing timestamp columns
Hi
Is it possible to make a timestamp column use a index in a query like
select foo from bar where timestamp <= smth?
It all seems ok when I use select foo from bar where timestamp = smth
Thanks
--
Pedro Miguel G. Alves pmalves@think.pt
THINK - Tecnologias de Informação www.think.pt
Tel: +351 21 412 56 56 Av. José Gomes Ferreira
Fax: +351 21 412 56 57 nº 13 1495-139 ALGÉS
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