Re: Pushing IN (subquery) down through UNION ALL? - Mailing list pgsql-performance

From Vik Reykja
Subject Re: Pushing IN (subquery) down through UNION ALL?
Date
Msg-id AANLkTi=hnXV9gZ3y93cdLoiND3FbAXZraZrWH+=PLRiz@mail.gmail.com
Whole thread Raw
In response to Re: Pushing IN (subquery) down through UNION ALL?  (Dave Johansen <davejohansen@gmail.com>)
Responses Re: Pushing IN (subquery) down through UNION ALL?
List pgsql-performance
On Thu, Feb 24, 2011 at 20:56, Dave Johansen <davejohansen@gmail.com> wrote:
On Thu, Feb 24, 2011 at 12:33 PM, Vik Reykja <vikreykja@gmail.com> wrote:
On Thu, Feb 24, 2011 at 16:14, Dave Johansen <davejohansen@gmail.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?
 
Thanks a ton,

You're welcome.

pgsql-performance by date:

Previous
From: Dave Johansen
Date:
Subject: Re: Pushing IN (subquery) down through UNION ALL?
Next
From: Merlin Moncure
Date:
Subject: Re: Picking out the most recent row using a time stamp column