我试图找出为什么一个SQL Server存储过程执行慢,所以我把一些原油定时器,像这样:SQL存储过程的执行时间之谜
Create Procedure DoStuff
As Begin
Declare @Stopwatch datetime
Set @Stopwatch=GetDate()
Print char(13) + 'Task A'
/* Perform Task A */
Print DateDiff(ms, @Stopwatch, GetDate()); Set @Stopwatch = GetDate()
Print char(13) + 'Task B'
/* Perform Task B */
Print DateDiff(ms, @Stopwatch, GetDate()); Set @Stopwatch = GetDate()
Print char(13) + 'Task C'
-- Perform Task C
Print DateDiff(ms, @Stopwatch, GetDate()); Set @Stopwatch = GetDate()
End
Exec DoStuff
我越来越这样的事情:
Task A 0 Task B 80 Task C 100
所以我会认为该过程将需要180毫秒执行。但是,该过程需要3000+ ms才能执行;在客户端统计,我得到
Client processing time: 12 Total execution time: 3105 Wait time on server replies: 3093
的额外〜2800毫秒的原因是什么?