SQL Server: Optimizing Stored Procedure Performance

When using stored procedures, their performance is dependent on creating the optimal plan for the execution environment and making sure that it remains cached. This comprehensive course will show you all of that and more, and is applicable to SQL Server developers and anyone responsible for ensuring performance of stored procedures, from SQL Server 2005 onward.
Course info
Rating
(283)
Level
Intermediate
Updated
Aug 28, 2014
Duration
7h 10m
Table of contents
Introduction
Why Use Stored Procedures?
Creation, Compilation, and Invalidation Section 1
Creation, Compilation, and Invalidation Section 2
Optimization and Recompilation Section 1
Optimization and Recompilation Section 2
Optimization and Recompilation Section 3
Optimization and Recompilation Section 4
Other Concerns and Considerations
Description
Course info
Rating
(283)
Level
Intermediate
Updated
Aug 28, 2014
Duration
7h 10m
Description

If you want to use SQL Server databases effectively, you will end up using stored procedures. Their aim is that you have optimized and compiled code that resides in a cache to improve workload performance for subsequent executions. However, you might find that it does not always work out that way.

The performance of a stored procedure is heavily dependent on how the plan is chosen and cached. If the plan is not optimal for subsequent executions it could cause performance to suffer greatly. In the end, you might suffer from what is known as parameter-sniffing-problems where the optimal plan for a procedure varies based on the parameters supplied.

This comprehensive course will teach you how stored procedure plan caching works and how to get SQL Server to produce the optimal plan for your stored procedure performance in a variety of circumstances. The course is applicable to SQL Server developers and anyone who is responsible for writing stored procedures that must repeatedly perform well.

The demo database provided is compatible with SQL Server 2008 through SQL Server 2014. All course demos are shown on SQL Server 2014 with references to behaviors (where different) on all versions. Optimization strategies you will learn in the course apply to SQL Server 2005 onward, and some even back to SQL Server 2000.

Course FAQ
Course FAQ
What is a stored procedure in SQL Server?

Stored procedure is a piece of SQL code that is saved and can be reused as needed instead of writing the same SQL code over and over again. It can be used to insert, delete, or update a SQL statement, and much more.

What are some of the benefits of stored procedures?

SQL Server stored procedures help maintain data integrity through consistency. They also improve productivity because certain statements will only need to be written once instead of several times over.

What are the types of stored procedures?

Some of the different types of SQL Server Stored Procedures include:

  • System Defined Stored Procedures
  • Extended procedures - gives access to external programs
  • User Defined Stored Procedures - made by users for their own specific actions
  • CLR Stored Procedures - allows coding procedures in a .NET language
Who is this course for?

This course will be most applicable to SQL Server developers, but will be beneficial to anyone who wants to ensure productivity and performance working within SQL Server.

What will I learn in this course?

This course will teach you how stored procedure plan caching works and how to get SQL Server to produce the optimal plan for your stored procedure performance in a variety of circumstances.

You will learn:

  • Why it is effective to use stored procedures
  • How to create a stored procedure
  • Where stored procedures are stored
  • Stored procedure plans and caching
  • When you should recompile
  • Conditional logic
  • Much more
What version do I need for this course?

Course demos are shown on SQL Server 2014, but they are applicable as far back as SQL Server 2005 through today.

Are there prerequisites for this course?

Before taking this course you should be familiar with SQL Server fundamentals.

About the author
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 from the author
SQL Server: Indexing for Performance
Beginner
7h 11m
Sep 15, 2017
More courses by Kimberly L. Tripp