Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 9946464FF86 for ; Thu, 7 Aug 2008 05:36:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 50802-07 for ; Thu, 7 Aug 2008 05:35:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) by postgresql.org (Postfix) with ESMTP id D7ECA64FF05 for ; Thu, 7 Aug 2008 05:35:59 -0300 (ADT) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay05.plus.net with esmtp (Exim) id 1KR0yR-0000u1-AP; Thu, 07 Aug 2008 09:35:55 +0100 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 28622274065; Thu, 7 Aug 2008 09:35:55 +0100 (BST) Message-ID: <489AB3EB.8040903@archonet.com> Date: Thu, 07 Aug 2008 09:35:55 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.16 (X11/20080707) MIME-Version: 1.0 To: Giorgio Valoti CC: pgsql-performance@postgresql.org Subject: Re: Query Plan choice with timestamps References: <321506D5-4400-470C-909E-C7700D49A540@mac.com> In-Reply-To: <321506D5-4400-470C-909E-C7700D49A540@mac.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-Plusnet-Relay: a50433750aba1bd4c263e13be68f882a X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/31 X-Sequence-Number: 30912 Giorgio Valoti wrote: > Hi, I have a timestamptz field that I want to use with a query, but I=20 > don=92t need the full timestamp resolution, so I=92ve created a=20 > day_trunc(timestamptz) immutable function which I=92ll use with the que= ry=20 > and with a new index: >=20 > logs=3D> create index test_idx on blackbox (day_trunc(ts)); >=20 > However, the query plan doesn=92t use the index: Does it use it ever? e.g. with SELECT * FROM blackbox WHERE day_trunk(ts) =3D '...' --=20 Richard Huxton Archonet Ltd