Re: Index scan vs. Seq scan on timestamps

From: Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Index scan vs. Seq scan on timestamps
Date: 2004-12-06 21:14:01
Message-ID: slrncr9isp.sjo.andrew+nonews@trinity.supernews.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2004-12-06, Per Jensen <per(at)net-es(dot)dk> wrote:
> Why does PG not use the index on the time column in the second select,
> timeofday() has been cast to a timestamp after all.

"timestamp" is "timestamp without time zone" (not the most useful type in
the world). Your column is of type "timestamp with time zone" (correct).
The relationship between the two is not trivial and the lack of an index
scan therefore expected. Try casting to "timestamp with time zone" instead.

--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eric E 2004-12-06 21:20:24 Re: Auditing with shared username
Previous Message Greg Stark 2004-12-06 21:12:01 Re: select single entry and its neighbours using direct-acess to index?