How String Columns Can Mess Up Query Performance In SQL Server
In this video, I delve into how string data in your tables can significantly impact query performance, particularly focusing on memory grants. I explore a scenario where including a text column in a query leads to substantial memory grant issues and sort operations that spill to disk, causing significant delays. By comparing two similar queries-one with the text column selected and one without-I demonstrate the dramatic differences in execution time and resource usage. The video also highlights how even removing the text column from the final select list doesn't always prevent these issues, emphasizing the importance of proper indexing for string columns, especially when sorting is involved. Additionally, I provide an extreme example where selecting a large 'VARCHAR(MAX)' column leads to massive memory grants and spills, nearly exhausting temporary database space, leading to query failures. Through this analysis, I aim to underscore the potential pitfalls of storing large text data in your databases and suggest alternatives like using file pointers or other storage engines that might handle such data more efficiently. CHAPTERS 00:00:00 - Introduction 00:00:59 - Memory Grants and Columns 00:03:03 - Query Differences Explained 00:04:59 - Memory Grant Comparison 00:06:14 - Indexing for Performance 00:08:00 - Better Indexing Solutions 00:09:25 - Large Text Columns Impact 00:13:02 - TempDB Space Issues 00:17:04 - Query Plan Analysis 00:19:05 - Best Practices for Strings 00:20:04 - Conclusion ━━━━━━━━━━━━━━━━━━━━━━━━━━ 📚 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 ━━━━━━━━━━━━━━━━━━━━━━━━━━
Download
0 formatsNo download links available.