开发者

Large Table With Multiple Outer Apply Row Compare Performance

I have a large table with a sample query like below to retrieve matched results.

Select col1,col2,col3
from
Table1 T1
OUTER APPLY (select col2 from Table2 Where t2id=T1.id)
OUTER APPLY (select col3 from Table3 Where t3id=T1.id)
Where col3>0

problem is the its running extremely slow when I have the Where clause column valu开发者_StackOverflowe check.

I have tried different approach including CROSS APPLY, without any improvement to the performance.

Any idea?


Try moving the where clause inside the select statement. This should result in less rows to compute and therefore quicker results

Select col1,col2,col3
from
Table1 T1
OUTER APPLY (select col2 from Table2 Where t2id=T1.id)
OUTER APPLY (select col3 from Table3 Where t3id=T1.id Where col3>0)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜