Description:
In this video, I dive into the state of table variables in SQL Server, particularly focusing on their behavior as we approach the 25th anniversary since their introduction in SQL Server 2000. I explore how table variable deferred compilation and interleaved execution have evolved over time, especially with the release of SQL Server 2017 and 2019 features that attempt to improve cardinality estimation but fall short when it comes to statistical information within the table variable itself. The video delves into practical examples using SSMS, demonstrating how the number of rows in a table variable can significantly impact query plans, especially when dealing with parameter sniffing issues outside and inside stored procedures. I also touch on the upcoming SQL Server 2025 features and how they might influence our understanding and use of table variables in the future.
CHAPTERS
00:00:00 - Introduction to Table Variables and Cardinality Estimation Issues
00:03:58 - Example with Table Variable and Poor Query Plan
00:06:29 - Explanation of Histogram and Statistics Lack for Table Variables
00:08:41 - Stored Procedures and Table Value Parameters
00:10:27 - Table Type vs. Table Variable in SQL Server
00:13:03 - Recap of Poor Cardinality Estimation with Table Variables
00:15:30 - Deferred Table Variable Compilation in SQL Server 2019
00:16:48 - Real-World Implications and Client Workaround Needs
00:17:08 - Conclusion and Encouragement for Further Learning
━━━━━━━━━━━━━━━━━━━━━━━━━━
???? 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














































