2

I have a simple stored procedure as an example, which reads a table with 3 rows.

CREATE PROCEDURE demo_procedure
AS
    BEGIN
        SELECT * FROM my_table
    END

When I run it with time statistics on:

SET STATISTICS TIME ON
GO
exec demo_procedure
GO

I get:

SQL Server parse and compile time: 
   CPU time = 0 ms, elapsed time = 0 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.
SQL Server parse and compile time: 
   CPU time = 0 ms, elapsed time = 0 ms.
SQL Server parse and compile time: 
   CPU time = 0 ms, elapsed time = 2 ms.

(3 rows affected)

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

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 3 ms.

How should I read this data? Does the stored procedure takes 2 ms, 3 ms or 5 ms?

3

Parse and compile is the time it takes to validate syntax and object validity, then compile an execution plan. Elapsed time is how long it takes the query to execute and finish returning rows to the client (SSMS). If you're returning a lot of rows, the query itself may be done long before rows are done rendering in SSMS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.