In this video, I delve into some quirky issues related to working with dates in SQL Server databases. I share two amusing examples from recent client projects where the solutions were surprisingly simple but not always obvious. First, I demonstrate how using the 'AT TIME ZONE' function incorrectly on a column can severely impact performance, showing that applying it to a variable instead yields much better results. Second, I explore an over-communicative query pattern where filtering by date and time unnecessarily complicates the execution plan, leading to excessive reads. By stripping down the query and using the right data types, we achieve a more efficient and cleaner execution plan. If you find these SQL Server tips helpful or entertaining, don't forget to like this video, leave a comment (though I might challenge overly negative ones in person), subscribe for future content, and consider hiring me for your own database optimization needs!
CHAPTERS
00:00:00 - Introduction to Date Handling in SQL Server
00:02:35 - Seeking and Residual Predicates with Dates
00:04:57 - Optimizer Rules for Temporal Data
00:06:19 - Example Query Plan Analysis
00:08:41 - Performance Considerations in Query Plans
00:10:23 - Simplifying Date Queries
00:12:00 - Conclusion and Final Thoughts
━━━━━━━━━━━━━━━━━━━━━━━━━━
📚 TRAINING & COURSES
━━━━━━━━━━━━━━━━━━━━━━━━━━
Get AI-Ready With Erik
https://training.erikdarling.com/get-...
SQL Server Performance Engineering Course
https://training.erikdarling.com/sql-...
Learn T-SQL with Erik
https://training.erikdarling.com/lear...
Everything Bundle:
https://training.erikdarling.com/?cou...
━━━━━━━━━━━━━━━━━━━━━━━━━━
🛠️ CONSULTING & SERVICES
━━━━━━━━━━━━━━━━━━━━━━━━━━
Need SQL Server performance help?
https://training.erikdarling.com/sqlc...
━━━━━━━━━━━━━━━━━━━━━━━━━━
💬 CONNECT
━━━━━━━━━━━━━━━━━━━━━━━━━━
Ask questions at Office Hours
https://erikdarling.com/officehours/
Become a channel member
/ @erikdarlingdata
━━━━━━━━━━━━━━━━━━━━━━━━━━