SQL Server: Optimizing Ad Hoc Statement Performance

by Kimberly L. Tripp

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

About the author

Kimberly L. Tripp is a SQL Server MVP and a Microsoft Regional Director and has worked with computers since 1985. Since 1995, Kimberly has worked as a Speaker, Writer, Trainer and Consultant for her own company SQLskills.com which she now runs with her husband – Paul Randal. Working together Kimberly and Paul enjoy the ability to work on different types of projects – from Immersion Events to consulting to speaking at conferences to writing articles and books. Kimberly has presented lectures and ... more

Ready to upskill? Get started