Queries not always using index on timestamp search

From: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
To: pgsql-general(at)postgresql(dot)org (pgsql general list)
Subject: Queries not always using index on timestamp search
Date: 2004-06-24 14:59:58
Message-ID: 200406241459.i5OExwaI025590@gw.tssi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here are two queries (under 7.4.1):

'mytime' is a timestamp field that is indexed.

select * from mytable where mytime > '2004-06-21'

select * from mytable where mytime > current_date-3

Looking at an explain on these queries, the first one will use the
index and the second one will not, even though 'current_date-3'
produces the same date as the hard-coded one in the first search.

Is there a way to get the second query to use the index?
--
Mike Nolan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GUNDUZ 2004-06-24 15:03:17 7.4.3 RPMS for RHEL3
Previous Message Tatsuo Ishii 2004-06-24 14:27:24 Re: unicode and sorting(at least)