Description:
In this video, I delve into the intricacies of multi-statement table-valued functions (MTVF) in SQL Server, specifically focusing on parameter sensitivity and plan caching issues. Building upon yesterday's discussion about scalar UDFs, today's episode explores how these functions behave differently when recompiled, leading to varying execution plans and performance impacts. I demonstrate this through a series of demos, highlighting the differences between using a function with and without an 'OPTION (RECOMPILE)' hint, and explain why certain execution plans are chosen over others. By running multiple executions and analyzing query plans in QuickQueryStore, we uncover how SQL Server handles plan caching for these functions, revealing the parameter sniffing problem that can arise. If you have encountered similar issues with your own functions or need help optimizing them, consider reaching out for consulting services. Additionally, supporting my channel as a member of the community will ensure you don't miss any future insights on T-SQL and database performance optimization.
CHAPTERS
00:00:00 - Introduction
00:02:11 - ScalarUDF vs Multistatement Functions
00:04:07 - Query Plan Analysis for First Function
00:05:31 - Execution Plans Comparison
00:08:44 - Parameter Sensitivity Issue
00:10:05 - Summary and Next Steps
-
TRAINING & COURSES
-
Get AI-Ready With Erik
https://training.erikdarling.com/get-ai-ready-with-erik?coupon=AIREADY
SQL Server Performance Engineering Course
https://training.erikdarling.com/sql-server-performance-engineering?coupon=ENGINEERING
Learn T-SQL with Erik
https://training.erikdarling.com/learn-t-sql-with-erik?coupon=ADVANCEDTSQL
Everything Bundle:
https://training.erikdarling.com/?coupon=SPRINGCLEANING
-
CONSULTING & SERVICES
-
Need SQL Server performance help?
https://training.erikdarling.com/sqlconsulting
-
CONNECT
-
Ask questions at Office Hours
https://erikdarling.com/officehours/
Become a channel member
https://www.youtube.com/@ErikDarlingData/join
-
Share this link via
Or copy link















































