Re: Difference between "foo is false" and "foo=false"? Partial index on boolean.

From: Richard Huxton <dev(at)archonet(dot)com>
To: Bryce Nesbitt <bryce1(at)obviously(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Difference between "foo is false" and "foo=false"? Partial index on boolean.
Date: 2007-09-04 08:43:52
Message-ID: 46DD1AC8.7050407@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bryce Nesbitt wrote:
> Tom Lane wrote:
>> Bryce Nesbitt <bryce1(at)obviously(dot)com> 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bart Degryse 2007-09-04 09:03:43 Use of delete...returning in function problem
Previous Message Marc Mamin 2007-09-04 08:35:55 EXECUTE 'EXECUTE ...' or how to use dynamic prepared statements ?