[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 (

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

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