Re: [PERFORM] Terrible plan for join to nested union

2012-07-08 Thread Nate Allan
>Right now, UNION DISTINCT, along with INTERSECT and EXCEPT, have basically no >optimization support whatsoever... > Sorry to be the bearer of bad news, but this isn't going to change just > because you try to label it a bug. Given the medium, I'll try not to read that in a snarky tone, after al

Re: [PERFORM] Terrible plan for join to nested union

2012-07-08 Thread Tom Lane
Nate Allan writes: > 2) Why would more effort go into Union All rather than Union? The UNION ALL case matches up with, and shares planning and execution code with, table-inheritance and partitioning scenarios. So yes, it really is more interesting to more people than UNION DISTINCT. (IIRC, the c

Re: [PERFORM] Terrible plan for join to nested union

2012-07-08 Thread Nate Allan
>>Nate Allan writes: >> It seems to me that the join condition (and hence the restriction) should be >> pushed down into both sides of the union to bring the cardinality limit from >> millions to 1. I'm imagining a rewrite like this: >> R(a) J (b U c) -> (b J R(a)) U (c J R(a)) ...wher

Re: [PERFORM] Terrible plan for join to nested union

2012-07-08 Thread Tom Lane
Nate Allan writes: > It seems to me that the join condition (and hence the restriction) should be > pushed down into both sides of the union to bring the cardinality limit from > millions to 1. I'm imagining a rewrite like this: > R(a) J (b U c) -> (b J R(a)) U (c J R(a)) > ...where R

Re: [PERFORM] Terrible plan for join to nested union

2012-07-08 Thread Nate Allan
>you are using EAV schema - it is against to relation model enough :) >this schema has the most terrible performance for large datasets - looks on >hstore instead >Pavel Actually despite the table named Attribute, I am not doing EAV though I can see why you'd think that. Attributes are part of

Re: [PERFORM] Terrible plan for join to nested union

2012-07-07 Thread Pavel Stehule
2012/7/8 Nate Allan : > Thanks for your reply Tom. > >>> I have a query which joins to a nested union and I'm getting a plan which >>> never returns. Here is the query simplified as much as possible: >>> select 'anything' as result >>>from "Attribute" as A1 >>>

Re: [PERFORM] Terrible plan for join to nested union

2012-07-07 Thread Nate Allan
Thanks for your reply Tom. >> I have a query which joins to a nested union and I'm getting a plan which >> never returns. Here is the query simplified as much as possible: >> select 'anything' as result >>from "Attribute" as A1 >> inner join >>

Re: [PERFORM] Terrible plan for join to nested union

2012-07-07 Thread Tom Lane
Nate Allan writes: > I have a query which joins to a nested union and I'm getting a plan which > never returns. Here is the query simplified as much as possible: > select 'anything' as result >from "Attribute" as A1 > inner join >

[PERFORM] Terrible plan for join to nested union

2012-07-07 Thread Nate Allan
I have a query which joins to a nested union and I'm getting a plan which never returns. Here is the query simplified as much as possible: select 'anything' as result from "Attribute" as A1 inner join (