SQL 服务器会话任务全部在等待

SQL 服务器会话任务全部在等待

我有一个查询通常在几分之一秒内(~200ms)完成。

有时需要 10-13 秒才能完成。执行SET STATISTICS TIME ON后显示:

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

这是此数据库实例上唯一活跃的事物。此外,查询sys.dm_os_waiting_tasks它显示所有任务都在等待 CXPACKET,但它们都在等待彼此,没有任务不在等待。

0x0000000003D81048  54  28  4569    CXPACKET    0x000000021F3513B0  0x00000001F18CE088  54  39  exchangeEvent id=Pipe13f667850 WaitType=e_waitPipeGetRow nodeId=13
0x00000001F18CE088  54  39  4569    CXPACKET    0x0000000209290080  0x00000000040BF048  54  30  exchangeEvent id=Pipe12d828cd0 WaitType=e_waitPipeNewRow nodeId=13
0x00000001F18CE2C8  54  24  8240    CXPACKET    0x00000001318BBBC0  0x000000000409A988  54  29  exchangeEvent id=Pipe1319daba0 WaitType=e_waitPipeGetRow nodeId=11
0x00000001F18CE748  54  30  8236    CXPACKET    0x00000001F6CFF960  0x000000021D1182C8  54  21  exchangeEvent id=Pipeea331060 WaitType=e_waitPipeGetRow nodeId=6
0x000000000409A988  54  29  8243    CXPACKET    0x00000001F5F373B0  0x00000001F18CE088  54  39  exchangeEvent id=Port8025e600 WaitType=e_waitPortClose nodeId=13
0x000000021D1182C8  54  21  8241    CXPACKET    0x00000001FA1B5BC0  0x000000000409A988  54  29  exchangeEvent id=Pipe1f5e6cee0 WaitType=e_waitPipeGetRow nodeId=11
0x000000021D118748  54  25  8236    CXPACKET    0x00000001E4D71960  0x000000021D1182C8  54  21  exchangeEvent id=Pipe12d890a00 WaitType=e_waitPipeGetRow nodeId=6
0x00000000040B4E08  54  0   8236    CXPACKET    0x00000001E9206890  0x000000021D118748  54  25  exchangeEvent id=Pipe1ee39e800 WaitType=e_waitPipeGetRow nodeId=1
0x00000000040B4E08  54  0   8236    CXPACKET    0x00000001E9206890  0x000000013F684508  54  27  exchangeEvent id=Pipe1ee39e800 WaitType=e_waitPipeGetRow nodeId=1
0x00000000040B4E08  54  0   8236    CXPACKET    0x00000001E9206890  0x0000000090DB0BC8  54  32  exchangeEvent id=Pipe1ee39e800 WaitType=e_waitPipeGetRow nodeId=1
0x00000000040B4E08  54  0   8236    CXPACKET    0x00000001E9206890  0x00000000A5800508  54  31  exchangeEvent id=Pipe1ee39e800 WaitType=e_waitPipeGetRow nodeId=1
0x00000000040B4E08  54  0   8236    CXPACKET    0x00000001E9206890  0x00000001F195E508  54  28  exchangeEvent id=Pipe1ee39e800 WaitType=e_waitPipeGetRow nodeId=1
0x00000000040B4E08  54  0   8236    CXPACKET    0x00000001E9206890  0x0000000083E90BC8  54  26  exchangeEvent id=Pipe1ee39e800 WaitType=e_waitPipeGetRow nodeId=1
0x00000000040B4E08  54  0   8236    CXPACKET    0x00000001E9206890  0x00000001E7A32748  54  29  exchangeEvent id=Pipe1ee39e800 WaitType=e_waitPipeGetRow nodeId=1
0x00000000040B4E08  54  0   8236    CXPACKET    0x00000001E9206890  0x00000001F18CE748  54  30  exchangeEvent id=Pipe1ee39e800 WaitType=e_waitPipeGetRow nodeId=1
0x00000000040B4BC8  54  32  8242    CXPACKET    0x00000001EF9C53B0  0x00000001F18CE088  54  39  exchangeEvent id=Port8025e600 WaitType=e_waitPortClose nodeId=13
0x00000001E7A322C8  54  18  8241    CXPACKET    0x0000000221DC3BC0  0x000000000409A988  54  29  exchangeEvent id=Pipe1e5a45ad0 WaitType=e_waitPipeGetRow nodeId=11
0x00000001E7A32748  54  29  8236    CXPACKET    0x000000021CEE9960  0x000000021D1182C8  54  21  exchangeEvent id=Pipe1ecd3a5c0 WaitType=e_waitPipeGetRow nodeId=6
0x00000000040BF048  54  30  4569    CXPACKET    0x000000012FA3C290  0x000000021D1182C8  54  21  exchangeEvent id=Pipe131a606b0 WaitType=e_waitPipeNewRow nodeId=11
0x00000000040BF4C8  54  22  8240    CXPACKET    0x00000001F50D3BC0  0x000000000409A988  54  29  exchangeEvent id=Pipe1319daac0 WaitType=e_waitPipeGetRow nodeId=11
0x0000000090DB0BC8  54  32  8236    CXPACKET    0x00000001E67D7960  0x000000021D1182C8  54  21  exchangeEvent id=Pipe1eed8c5b0 WaitType=e_waitPipeGetRow nodeId=6
0x00000000041E8988  54  27  8243    CXPACKET    0x00000000A55573B0  0x00000001F18CE088  54  39  exchangeEvent id=Port8025e600 WaitType=e_waitPortClose nodeId=13
0x000000013F684088  54  17  8241    CXPACKET    0x00000001FA8FFBC0  0x000000000409A988  54  29  exchangeEvent id=Pipe1319db030 WaitType=e_waitPipeGetRow nodeId=11
0x000000013F684508  54  27  8236    CXPACKET    0x00000001E9309960  0x000000021D1182C8  54  21  exchangeEvent id=Pipe1ecd3b600 WaitType=e_waitPipeGetRow nodeId=6
0x0000000004203048  54  26  8235    CXPACKET    0x00000001007FE290  0x000000021D1182C8  54  21  exchangeEvent id=Pipe202f84ea0 WaitType=e_waitPipeNewRow nodeId=11
0x00000000A5800088  54  19  8241    CXPACKET    0x00000001F1DD5BC0  0x000000000409A988  54  29  exchangeEvent id=Pipe12ed0b0e0 WaitType=e_waitPipeGetRow nodeId=11
0x00000000A5800508  54  31  8236    CXPACKET    0x00000001F3D2F960  0x000000021D1182C8  54  21  exchangeEvent id=Pipea2b3a570 WaitType=e_waitPipeGetRow nodeId=6
0x000000000421C988  54  25  8243    CXPACKET    0x00000001F345B3B0  0x00000001F18CE088  54  39  exchangeEvent id=Port8025e600 WaitType=e_waitPortClose nodeId=13
0x00000001F195E088  54  23  8241    CXPACKET    0x00000001EA6E3BC0  0x000000000409A988  54  29  exchangeEvent id=Pipe1f3c22f70 WaitType=e_waitPipeGetRow nodeId=11
0x00000001F195E508  54  28  8236    CXPACKET    0x00000001F4945960  0x000000021D1182C8  54  21  exchangeEvent id=Pipea2b3a400 WaitType=e_waitPipeGetRow nodeId=6
0x0000000083E902C8  54  31  8242    CXPACKET    0x00000000E834D3B0  0x00000001F18CE088  54  39  exchangeEvent id=Port8025e600 WaitType=e_waitPortClose nodeId=13
0x0000000083E90748  54  20  8241    CXPACKET    0x00000001E7A23BC0  0x000000000409A988  54  29  exchangeEvent id=Pipe12ed0b220 WaitType=e_waitPipeGetRow nodeId=11
0x0000000083E90BC8  54  26  8236    CXPACKET    0x00000001F0C6B960  0x000000021D1182C8  54  21  exchangeEvent id=Pipe1301e64a0 WaitType=e_waitPipeGetRow nodeId=6

我在这里抓狂不已,我怀疑这是由于机器配置而不是查询本身造成的。它在查询中执行了大量连接,但没有造成执行时间的差异。计划每次都是一样的。

我是否可以在性能监视器或类似工具中观察某些内容,以便有时能给我提供一些线索来了解导致执行延迟的原因?

相关内容