From: Steinar H. Gunderson <sgunderson@bigfoot.com>
To: pgsql-performance@postgresql.org
Subject: Re: Why does a simple query not use an obvious index?
Date: Sun, 29 Aug 2004 20:57:50 +0200
Message-ID: <20040829185750.GA30018@uio.no> (raw)
In-Reply-To: <20040829180448.41247.qmail@web41108.mail.yahoo.com>
References: <ENEIKKAEJOFHOIHMMOIDIEBMJCAA.jack.kerkhof@guest-tek.com>
<20040829180448.41247.qmail@web41108.mail.yahoo.com>
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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: sgunderson@bigfoot.com
Subject: Re: Why does a simple query not use an obvious index?
In-Reply-To: <20040829185750.GA30018@uio.no>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox