Re: Pushing IN (subquery) down through UNION ALL?

From: Dave Johansen <davejohansen(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Pushing IN (subquery) down through UNION ALL?
Date: 2011-02-24 20:51:53
Message-ID: AANLkTin1mpf=fabt5nvOAnfkBTRR+taVtODTnsKusCn3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Feb 24, 2011 at 12:59 PM, Vik Reykja <vikreykja(at)gmail(dot)com> wrote:

> On Thu, Feb 24, 2011 at 20:56, Dave Johansen <davejohansen(at)gmail(dot)com>wrote:
>
>> On Thu, Feb 24, 2011 at 12:33 PM, Vik Reykja <vikreykja(at)gmail(dot)com> wrote:
>>
>>> On Thu, Feb 24, 2011 at 16:14, Dave Johansen <davejohansen(at)gmail(dot)com>wrote:
>>>
>>>> You'll notice that the subquery version is doing the full join and then
>>>> the filtering, but the explicitly listed version pushing the filtering into
>>>> the plan before the join. Is there a way to make the subquery version
>>>> perform the same optimization?
>>>>
>>>
>>> EXPLAIN ANALYZE SELECT * FROM addressesall WHERE id = ANY (array(SELECT
>>> id FROM users WHERE name='A'));
>>>
>>> (Tested on 9.0.3)
>>>
>>
>> I just tested that on 8.3.3 and it performed quickly like I expected the
>> other query to, so that did the trick.
>>
>
> Is there any good reason you're not using 8.3.14?
>

No, I just haven't taken the time to do the upgrade on all of our systems.
It is definitely something that I have started to consider more strongly
though.

Dave

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2011-02-24 21:14:59 Re: Picking out the most recent row using a time stamp column
Previous Message Kevin Grittner 2011-02-24 20:24:15 Re: Picking out the most recent row using a time stamp column