开发者

index seek while calling the UDF itself, index scan while wrapping the UDF in sp

开发者 https://www.devze.com 2023-01-19 08:18 出处:网络
I have a UDF that does most of the joins and when I run it, it read about 100-150 pages (from sql profiler) but if I wrap this UDF in sp then the sp will do the read about 243287 p开发者_C百科ages.

I have a UDF that does most of the joins and when I run it, it read about 100-150 pages (from sql profiler) but if I wrap this UDF in sp then the sp will do the read about 243287 p开发者_C百科ages.

Furthermore, the UDF itself performs index seek but the sp performs index scan on one of the searched columns.

Can anyone please advise?


Based on your comments about (custid = @param1 OR @param1 is null) vs. (custid = @param1), I think Gail Shaw's blog posting on Catch-all queries will provide some insight into what you're seeing here. Basically, I think you're getting an execution plan cached for the @param1 is null case that then performs poorly when you pass in a real @param1.

0

精彩评论

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

关注公众号