Re: query for a time interval

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Mark <sendmailtomark(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: query for a time interval
Date: 2005-12-23 15:22:55
Message-ID: 19830.1135351375@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael Fuhr <mike(at)fuhr(dot)org> writes:
> Unless I'm missing something that wouldn't use an index either,
> because the planner wouldn't know what value to compare start_date
> against without hitting each row to find that row's time_to_live.
> But something like this should be able to use an expression index
> on (start_date + time_to_live):

> WHERE start_date + time_to_live < now()

Or perhaps simpler, get rid of time_to_live in favor of an end_date
column, which could be indexed directly.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-12-23 16:04:50 Re: Indices for select count(*)?
Previous Message Peter Eisentraut 2005-12-23 15:12:37 Re: Indices for select count(*)?