-
Course
- Data
SQL Server: Optimizing Ad Hoc Statement Performance
When using ad hoc T-SQL statements, their performance is dependent on you choosing the correct execution method to ensure they are cached correctly and their plans are reused appropriately, and this course will show you all of that and more. This course is applicable to SQL Server developers and anyone who is responsible for writing ad hoc T-SQL statements that must perform well, from SQL Server 2005 onward
What you'll learn
This course is about how different ad hoc statement execution methods affect caching, plan reuse, memory and ultimately performance. Knowing when to use each method is important and understanding how SQL Server works will demystify certain behaviors you may have seen but previously have been unable to explain. SQL Server can support any workload, any design, and any data requests but knowing exactly which one is the most beneficial to use can give you better long-term scalability, availability, and performance. Using the wrong method can cause more memory to be wasted and even result in parameter sniffing problems (where subsequent statements perform poorly because of the plan that’s been cached). This course will show you how each statement execution method works, how it’s cached, whether or not it wastes cache, and finally how to test and rewrite the statement to take better advantage of caching. Along the way we will also cover a variety of other necessary features and tools: estimates, statistics, and heuristics; how to analyze query plans; some indexing strategies to improve performance; and plan guides. This course is an absolute must for everyone that works with SQL Server and it’s also an introduction to concepts that will be built upon in future courses. This course is applicable to all SQL Server versions from SQL Server 2005 onward, and for SQL Server developers as well as anyone responsible for writing data access statements to SQL Server tables. You can have any level of experience to gain from this course but those of you who have experienced what seemed odd behavior/performance with your ad hoc statements will probably benefit the most!
Table of contents
- Introduction and Background | 2m 52s
- This Course | 3m 55s
- What Does Optimizing Ad Hoc Statement Performance NOT Mean? | 3m 32s
- What Does Optimizing Ad Hoc Statement Performance Mean? | 2m 59s
- Why is This Course Relevant? | 3m 4s
- Course Focus and Structure (1) | 2m 8s
- Course Focus and Structure (2) | 2m 19s
- Introduction | 56s
- Different Ways to Execute SQL Statements | 3m 35s
- Understanding Ad Hoc Statements | 4m 39s
- Understanding sp_executesql | 3m 11s
- Understanding Dynamic String Execution | 4m 38s
- Dynamic String Execution and SQL Injection | 5m 20s
- Demo: Credit Sample Database Setup for This Course | 4m 22s
- Demo: Setting Up For Analyzing Cache | 8m 22s
- Demo: Part 1 - Ad Hoc Safe Statements | 8m 38s
- Demo: Part 2 - Ad Hoc Unsafe Statements | 7m 21s
- Demo: Part 3 - Ad Hoc Safe and Unsafe with Variables | 3m 34s
- Demo: Part 4 - sp_executesql with Safe Statement | 4m 21s
- Demo: Part 5 - sp_executesql with Unsafe Statement | 9m 1s
- Demo: Part 6 - Dynamic String Execution with Safe Statement | 8m 1s
- Demo: Part 7 - Dynamic String Execution with Unsafe Statement | 7m 21s
- Summary: Statement Execution Methods | 7m 4s
About the author
Kimberly is a SQL Server MVP, Microsoft Regional Director and President/Founder of SQLskills.com, which she now runs with her husband, Paul Randal. Kimberly’s areas of expertise focus on performance tuning through effective database design and architecture.
More Courses by Kimberly