Wednesday, February 16, 2022

Execution Time of Stored Procedures

Following command before you run the stored procedure and it will give you the final line in the message section with the time taken to run the execution plan for Stored Procedures.

1
2
SET STATISTICS TIME ON
EXEC YourSPName

The output will look something similar.

SQL Server Execution Times: CPU time = 500 ms, elapsed time = 1200 ms.

SQL Server Execution Times: CPU time = 100 ms, elapsed time = 150 ms.

SQL Server Execution Times: CPU time = 1500 ms, elapsed time = 2000 ms.

SQL Server Execution Times: CPU time = 2100 ms, elapsed time = 3250 ms.

If your stored procedure has three statements the first three represents the execution time of the individual query. However, the final last line represents the addition or commutative time for all the query statements together.

No comments:

Post a Comment