SQL Server 2008(不是R2),远程托管数据库。 SSMS 2008R2。
对于一些非常简单的查询,我经历了极长的查询时间,例如在这种情况下需要77秒才完成的查询
UPDATE Balances SET InUse WHERE BalanceId = 6;
问题是非常零星的,因为我可以一次又一次地运行相同的查询,并且它将在不到一秒的时间内运行,但偶尔会花费过多的时间来完成。以下是使用SET STATISTICS TIME ON和SET STATISTICS IO ON从上述查询输出的消息。
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 = 0 ms.
Table 'Balances'. Scan count 1, logical reads 38, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
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.
Table 'BalanceRevisionsAuto'. Scan count 10, logical reads 267106, physical reads 77634, read-ahead reads 80251, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 2312 ms, elapsed time = 77219 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.
Table 'BalanceRevisionsAuto'. Scan count 0, logical reads 1, physical reads 0, read ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Assets'. Scan count 0, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Balances'. Scan count 1, logical reads 38, physical reads 2, read-ahead reads 18, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 61 ms.
(1 row(s) affected)
SQL Server Execution Times:
CPU time = 2312 ms, elapsed time = 77300 ms.
(1 row(s) affected)
我对以下几点感到困惑:
为什么其他表“BalanceRevisionsAuto”,“Assets”在此查询中显示为对它们执行了逻辑读取?表之间没有外键关系,因此在更新期间需要检查其他关系。
在SQL Server执行时间下,经过时间= 77300ms是什么意思?我read“经过的时间包括这些元素:
信号等待时间
等待时间完成IO操作和
将输出传输到客户端所需的时间 这最后一项是否包括网络传输时间?
“已用时间”是否包括将数据恢复到请求计算机的时间?似乎我引用的文章说它确实如此。有没有办法把这个时间分开?
为什么“SQL Server执行时间”会出现六次?这些是查询计划的每个部分吗?