Skip site navigation (1) Skip section navigation (2)

Re: Indexing timestamp columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pedro Alves <pmalves(at)think(dot)pt>
Cc: PostGreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Indexing timestamp columns
Date: 2003-03-31 18:09:33
Message-ID: 24085.1049134173@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Pedro Alves <pmalves(at)think(dot)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


In response to

pgsql-general by date

Next:From: Steven SingerDate: 2003-03-31 18:23:43
Subject: Re: [Pgreplication-general] DBMIRROR and INSERT transactions lose
Previous:From: Joe ConwayDate: 2003-03-31 17:42:26
Subject: Re: plpgsql question

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group