Re: Why does a simple query not use an obvious index? - Mailing list pgsql-performance

From Steinar H. Gunderson
Subject Re: Why does a simple query not use an obvious index?
Date
Msg-id 20040829185750.GA30018@uio.no
Whole thread Raw
In response to Re: Why does a simple query not use an obvious index?  (Mr Pink <mr_pink_is_the_only_pro@yahoo.com>)
List pgsql-performance
On Sun, Aug 29, 2004 at 11:04:48AM -0700, Mr Pink wrote:
> Another is that if the condition data types don't match then an indes won't be used you could try:
>
>   select count(*) from billing where timestamp > (now()-60)::timestamp

In fact, I've had success with code like

    select count(*) from billing where timestamp > ( select now() - interval '1 minute' )

At least in my case (PostgreSQL 7.2, though), it made PostgreSQL magically do
an index scan. :-)

/* Steinar */
--
Homepage: http://www.sesse.net/

pgsql-performance by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: Why does a simple query not use an obvious index?
Next
From: Josh Berkus
Date:
Subject: Re: Equivalent praxis to CLUSTERED INDEX?