Re: Why does a simple query not use an obvious index?

From: "Steinar H(dot) Gunderson" <sgunderson(at)bigfoot(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Why does a simple query not use an obvious index?
Date: 2004-08-29 18:57:50
Message-ID: 20040829185750.GA30018@uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2004-08-29 18:59:01 Re: Equivalent praxis to CLUSTERED INDEX?
Previous Message Scott Marlowe 2004-08-29 18:28:48 Re: Why does a simple query not use an obvious index?