Re: Regression in IN( field, field, field ) performance

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Decibel! <decibel(at)decibel(dot)org>
Cc: Postgres Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Regression in IN( field, field, field ) performance
Date: 2008-10-21 20:47:26
Message-ID: 8930.1224622046@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Decibel! <decibel(at)decibel(dot)org> writes:
> On Oct 21, 2008, at 12:06 PM, Tom Lane wrote:
>> "Jim 'Decibel!' Nasby" <jnasby(at)cashnetusa(dot)com> writes:
>>> 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.

Works fine for me, eg

regression=# explain select * from tenk1 a, tenk1 b where
regression-# b.unique2 = any(array[a.unique1,a.ten,a.hundred]);
QUERY PLAN

--------------------------------------------------------------------------------
--
Nested Loop (cost=0.79..49047.50 rows=29997 width=488)
-> Seq Scan on tenk1 a (cost=0.00..458.00 rows=10000 width=244)
-> Bitmap Heap Scan on tenk1 b (cost=0.79..4.82 rows=3 width=244)
Recheck Cond: (b.unique2 = ANY (ARRAY[a.unique1, a.ten, a.hundred]))
-> Bitmap Index Scan on tenk1_unique2 (cost=0.00..0.79 rows=3 width=0
)
Index Cond: (b.unique2 = ANY (ARRAY[a.unique1, a.ten, a.hundred])
)
(6 rows)

You'll need to provide a concrete test case if you think there's
something broken here.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julius Stroffek 2008-10-21 20:49:36 Re: Multi CPU Queries - Feedback and/or suggestions wanted!
Previous Message Andrew Chernow 2008-10-21 20:00:24 Re: So what's an "empty" array anyway?