Re: [PERFORM] Poor plan when joining against a union containing a join

2013-03-08 Thread David Leverton
On 7 March 2013 18:47, Tom Lane wrote: > Good idea, but no such luck in that form: it's still not going to try to > push the parameterization down into the sub-query. I think you'd have > to write out the query with the views expanded and manually put the > WHERE restrictions into the lowest join

Re: [PERFORM] Poor plan when joining against a union containing a join

2013-03-07 Thread Tom Lane
David Leverton writes: > On 7 March 2013 05:52, Tom Lane wrote: >> Josh Berkus writes: >>> Actually, in case #4, Postgres *is* pushing down the join qual into the >>> segments of the Union. >> Yeah, but not further. I believe the core issue here (as of 9.2) is >> that we're not willing to gene

Re: [PERFORM] Poor plan when joining against a union containing a join

2013-03-07 Thread David Leverton
On 7 March 2013 05:52, Tom Lane wrote: > Josh Berkus writes: >> On 03/06/2013 06:54 AM, David Leverton wrote: >>> I'm encountering very poor query plans when joining against a union, > >> Actually, in case #4, Postgres *is* pushing down the join qual into the >> segments of the Union. > > Yeah, b

Re: [PERFORM] Poor plan when joining against a union containing a join

2013-03-06 Thread Tom Lane
Josh Berkus writes: > On 03/06/2013 06:54 AM, David Leverton wrote: >> I'm encountering very poor query plans when joining against a union, > Actually, in case #4, Postgres *is* pushing down the join qual into the > segments of the Union. Yeah, but not further. I believe the core issue here (as

Re: [PERFORM] Poor plan when joining against a union containing a join

2013-03-06 Thread Josh Berkus
On 03/06/2013 06:54 AM, David Leverton wrote: > Hi all, > > I'm encountering very poor query plans when joining against a union, > where one branch of the union is itself a join: specifically, Postgres > does the entire inside join and then filters the result, rather than > pushing the filters dow