Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 0AE109F960F for ; Tue, 4 Sep 2007 05:44:09 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 87524-03 for ; Tue, 4 Sep 2007 05:44:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id AF4E19F95FE for ; Tue, 4 Sep 2007 05:44:05 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id DC8D9143982; Tue, 4 Sep 2007 09:43:52 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 8F0C3274043; Tue, 4 Sep 2007 09:43:52 +0100 (BST) Message-ID: <46DD1AC8.7050407@archonet.com> Date: Tue, 04 Sep 2007 09:43:52 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: Bryce Nesbitt Cc: pgsql-sql@postgresql.org, Tom Lane Subject: Re: Difference between "foo is false" and "foo=false"? Partial index on boolean. References: <46DCE263.6040207@obviously.com> <14040.1188881806@sss.pgh.pa.us> <46DCE7F8.6080000@obviously.com> In-Reply-To: <46DCE7F8.6080000@obviously.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/25 X-Sequence-Number: 29238 Bryce Nesbitt wrote: > Tom Lane wrote: >> Bryce Nesbitt writes: >> >> They give different results for NULL --- specifically, NULL for the >> former and FALSE for the latter. Don't blame me, it's in the spec... > Thanks, and Got It. This particular column is: > reconciled | boolean | not null > On PostgreSQL 8.1.9. > So given all that, why would the Hibernate query fail to use the partial > index? I eventually created three indexes, and only the hideously large full > index increases performance: > Only the full index prevents a "false" scan from taking 4 seconds: > > LOG: duration: 4260.575 ms statement: EXECUTE C_50292 [PREPARE: select > count(vehicleeve0_.VEHICLE_EVENT_ID) as x0_0_ from EG_VEHICLE_EVENT vehicleeve0_ > where (vehicleeve0_.CSO_ID=$1 ) and (vehicleeve0_.*RECONCILED=$2* )] It's a prepared query-plan, which means it can't plan to use the index because the next EXECUTE might have reconciled=true. -- Richard Huxton Archonet Ltd