Analyzing Stored Procedures

When displaying the estimated execution plan for a stored procedure, you see multiple statement operators as inputs to the Stored Procedure operator, especially if you have any conditional branching in the stored procedure. One operator exists for each statement defined in the stored procedure. When conditional branching occurs in the stored procedure, SQL Server does not know at query optimization time which statements in the stored procedure will actually be executed, so it has to estimate a query plan for each individual statement. An example is shown in Figure 32.7.

Image

FIGURE 32.7 Estimated execution plan for a stored ...

Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.