I am trying to understand why the SQL Server stored procedure is slow, so I added some raw timers, for example:
Create Procedure DoStuff
As Begin
Declare @Stopwatch datetime
Set @Stopwatch=GetDate()
Print char(13) + 'Task A'
Print DateDiff(ms, @Stopwatch, GetDate()); Set @Stopwatch = GetDate()
Print char(13) + 'Task B'
Print DateDiff(ms, @Stopwatch, GetDate()); Set @Stopwatch = GetDate()
Print char(13) + 'Task C'
Print DateDiff(ms, @Stopwatch, GetDate()); Set @Stopwatch = GetDate()
End
Exec DoStuff
I get something like this:
Task a
0
Task b
80
Task c
one hundred
Therefore, I would have thought that 180 ms would be required to complete this procedure. However, this procedure requires 3000+ ms; in client statistics i get
Client processing time: 12
Total execution time: 3105
Wait time on server replies: 3093
What explains the extra ~ 2800 ms?
source
share