The first issue only happens in scalar functions, if you add a scalar function to your query, the function can’t be executed as a block and part of the query. It runs for every row found, which in small databases it won’t be a problem, after all, who cares about five executions. However, if you need to do it hundreds or thousands of times, it can get bad really fast.
The second issue with functions is that it ties SQL Server hands behind its back when it comes to parallelism, the engine can’t go parallel when a function is mentioned as part of the query simply because it doesn’t know how much it is going to be needed within the procedure. Let me show you how that works with a simple query.
Reference:
https://www.linkedin.com/pulse/why-functions-bad-sql-server-performance-marcelo-garrido-de-castro/
Comments
Post a Comment