我正在研究SQL SERVER 2008 R2性能调优部分,但我是新手。
如何计算:
等。由查询或存储过程创建。
有人可以帮我这个吗?
答案 0 :(得分:2)
抓取SQL Sentry Plan Explorer(免费),输入您的EXEC调用或查询,并生成实际的执行计划。您将获得各种有趣的指标,包括CPU和I / O.除了比管理工作室更有用的计划。
(免责声明:我为SQL Sentry工作。)
答案 1 :(得分:2)
SET STATISTICS IO
和SET STATISTICS TIME
是两个可以帮助您衡量存储过程查询执行情况的设置。
SET STATISTICS IO
显示有关查询生成的磁盘活动量的统计信息。 SET STATISTICS TIME
显示在查询中解析,编译和执行每个语句所需的时间。
USE <Your Database>;
GO
SET STATISTICS IO ON;
SET STATISTICS TIME ON;
GO
SELECT *
FROM YourTable
WHERE KeyValue > 1200
GO
SET STATISTICS IO OFF;
SET STATISTICS TIME OFF;
GO
可能的结果
Table 'YourTable'. Scan count 1, logical reads 5, 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 = 1 ms.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 1 ms.
(269 row(s) affected)
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 2 ms.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 1 ms.