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 Vol. 2 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.