From: Giorgio Valoti <giorgio_v@mac.com>
To: pgsql-performance@postgresql.org
Subject: Re: Query Plan choice with timestamps
Date: Thu, 07 Aug 2008 14:30:51 +0200
Message-ID: <15821866-9564-40E8-BC12-52ADD6D6EEA5@mac.com> (raw)
In-Reply-To: <489AB3EB.8040903@archonet.com>
References: <321506D5-4400-470C-909E-C7700D49A540@mac.com>
<489AB3EB.8040903@archonet.com>
On 07/ago/08, at 10:35, Richard Huxton wrote:
> Giorgio Valoti wrote:
>> Hi, I have a timestamptz field that I want to use with a query, but
>> I don’t need the full timestamp resolution, so I’ve created a
>> day_trunc(timestamptz) immutable function which I’ll use with the
>> query and with a new index:
>> logs=> create index test_idx on blackbox (day_trunc(ts));
>> However, the query plan doesn’t use the index:
>
> Does it use it ever? e.g. with
> SELECT * FROM blackbox WHERE day_trunk(ts) = '...'
It’s used:
logs=> explain select * from blackbox where day_trunc(ts) =
day_trunc(now());
QUERY PLAN
---------------------------------------------------------------------------
Bitmap Heap Scan on blackbox (cost=22.38..3998.43 rows=1239
width=264)
Recheck Cond: (day_trunc(ts) = day_trunc(now()))
-> Bitmap Index Scan on date_idx (cost=0.00..22.07 rows=1239
width=0)
Index Cond: (day_trunc(ts) = day_trunc(now()))
--
Giorgio Valoti
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: giorgio_v@mac.com
Subject: Re: Query Plan choice with timestamps
In-Reply-To: <15821866-9564-40E8-BC12-52ADD6D6EEA5@mac.com>
References: <321506D5-4400-470C-909E-C7700D49A540@mac.com> <489AB3EB.8040903@archonet.com> <15821866-9564-40E8-BC12-52ADD6D6EEA5@mac.com>
* 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