Re: Regression in IN( field, field, field ) performance - Mailing list pgsql-hackers

From Decibel!
Subject Re: Regression in IN( field, field, field ) performance
Date
Msg-id 75B003A6-F923-4DFD-AA32-6AA6A35D1D2C@decibel.org
Whole thread Raw
In response to Re: Regression in IN( field, field, field ) performance  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Regression in IN( field, field, field ) performance
List pgsql-hackers
On Oct 21, 2008, at 12:06 PM, Tom Lane wrote:
> "Jim 'Decibel!' Nasby" <jnasby@cashnetusa.com> writes:
>>        WHERE 'xxxxxxxxxxx' IN (people.home_phone, people.work_phone,
>> people.mobile_phone)
>
>> Yeah, not exactly a common case, but at least in 8.1 this was turned
>> into a set of ORs. Starting in 8.2 and in current HEAD, the planner
>> turns that into:
>
>> Filter: ('xxxxxxxxxxx'::text = ANY ((ARRAY[home_phone, mobile_phone,
>> work_phone])::text[]))
>
>> Which means automatic seqscan.
>
> It means no such thing.

It won't use an index scan on this query while it's in that form  
(even with enable_seqscan=off), but if I change it to a bunch of OR'd  
conditions it will switch to bitmap scans. The estimated cost with  
the seqscans is about 2x more expensive.
-- 
Decibel!, aka Jim C. Nasby, Database Architect  decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: So what's an "empty" array anyway?
Next
From: "Merlin Moncure"
Date:
Subject: Re: So what's an "empty" array anyway?