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 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 &g

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

2013-03-06 Thread David Leverton
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 down to the joined tables. I've provided a standalone test c