Subject | Strange performance on a VIEW |
---|---|
Author | Ben Ziegler |
Post date | 2005-07-28T22:33Z |
Thanks in advance to anyone who can help me with this.
I have a view (lets call it V_VIEW).
When I run a query like this:
select * from V_VIEW where ID = X
it is SLOW
But if I don't use the view, and just take the SQL that makes up
V_VIEW and put the "where ID = X" into that SQL, it is FAST
any idea why that would happen?
V_VIEW looks like sort of like this:
select ID, A, B, t2.C, sum(t2.D)
from table1 t1
left join table2 t2 on t1.ID = t2.ID
group by ID, A, B, C
I have a view (lets call it V_VIEW).
When I run a query like this:
select * from V_VIEW where ID = X
it is SLOW
But if I don't use the view, and just take the SQL that makes up
V_VIEW and put the "where ID = X" into that SQL, it is FAST
any idea why that would happen?
V_VIEW looks like sort of like this:
select ID, A, B, t2.C, sum(t2.D)
from table1 t1
left join table2 t2 on t1.ID = t2.ID
group by ID, A, B, C