Client Management Suite

 View Only

T-SQL UDFs and Performance 

Sep 19, 2014 06:43 AM

Today I was reviewing one of my T-SQL User Defined Functions (UDFs) and got distracted on the SQL Blog site, sqlblog.com

An article by Hugo Kornelis  had caught my attention, T-SQL User-Defined Functions: the good, the bad, and the ugly

This caught my eye as as I often create T-SQL User Defined Functions (UDFs) in order to simplify the look of my T-SQL code and make pieces of it easier to maintain in the long term. Hugo however demonstrates quite clearly how implementing scalar UDFs can be really, really bad. The problem is their performance can't be optimised by the SQL engine, so each call to the UDF comes with the same cost. He then demonstrates massive performance gains by putting even simple UDF code in-line in your T-SQL.

His bad news doesn't end there -the execution plans also lie about the cost, hiding this issue from those attempting to be sensible regarding their query execution times.

From the blog comments this is apparently widely known. I am stunned.

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Related Entries and Links

No Related Resource entered.