Why are there performance differences when a SQL function is called from .Net app vs when the same call is made in Management Studio

后端 未结 3 1598
难免孤独
难免孤独 2021-01-12 05:10

We are having a problem in our test and dev environments with a function that runs quite slowly at times when called from an .Net Application. When we call this function di

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 05:52

    I had similar problem with stored procedures, and for me it turned out to be 'parameter sniffing'. Google that and see if it solves your problem, for me it was dramatic speed-up once I fixed it.

    In my case, I fixed it by declaring a local variable for each parameters that was passed in, and then assigned the local variable to that parameter value, and the rest of the proc used the local variables for processing...for whatever reason, this defeated the parameter sniffing.

提交回复
热议问题