Chapter 20. Death by UDF
Kevin Boles
When Microsoft released SQL Server 2000, developers around the world rejoiced at the introduction of user-defined functions (UDFs). They were finally able to, within their Transact-SQL code, adhere to two of the main developer mantras: code encapsulation and code reuse. But unfortunately scalar UDFs weren’t fully integrated into the SQL Server optimizer and relational engine. This resulted in a number of issues, some of which can lead to unbelievably horrible query performance. In this chapter I’ll focus on two of these issues: bad optimizer estimates and especially row-by-row query processing. I’ll use a variety of standard tuning devices, including STATISTICS IO output, query plan analysis, and Profiler ...
Get SQL Server MVP Deep Dives, Volume 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.