Re: [PERFORM] Slow query when used in a view

2013-03-12 Thread Shaun Thomas
On 03/11/2013 06:56 PM, Tom Lane wrote: And that means that you get the inefficient plan wherein the foo-to-tiny_foo join is computed in its entirety. :( That's unfortunate, though I guess it makes sense. I moved the join in the view into the SELECT clause as an EXISTS, and that seems to wor

Re: [PERFORM] Slow query when used in a view

2013-03-11 Thread Tom Lane
Shaun Thomas writes: > A developer was complaining about a view he created to abstract an added > column in a left join. ... > Curious, I whipped up this test case: > CREATE VIEW v_slow_view AS > SELECT foo.*, tf.small_label IS NOT NULL AS has_small_label >FROM foo >LEFT JOIN tiny_foo tf

[PERFORM] Slow query when used in a view

2013-03-11 Thread Shaun Thomas
Hey everyone! A developer was complaining about a view he created to abstract an added column in a left join. He was contemplating denormalizing the added value into the parent table and using a trigger to maintain it instead, and I obviously looked into the problem. I noticed the view was in