Why calling a function takes much more time than direct execution of function code
问题 In my SQL Server 2008 R2 database, I have a query which calls a function. Lately this query has started to execute very slowly. I found that the user-defined function is hampering all the query. I tried to execute this function alone and it took 40 seconds to finish, while previously it executed in 3-4 seconds. So I tried to execute code that is inside of function and executed in this 3-4 seconds. I cannot understand why executing code of function takes far fewer time than calling function