|
网站建设语言中ASP.NET常对应使用的数据库是MSSQL,在MSSQL使用中如何查看SQL语句执行的时间,我们以下通过用SQL语句来测试,得出他的执行效率,让各位网站编码人员能更好地掌握.我们的方法是通过设置STATISTICS我们可以查看执行SQL时的系统情况。选项有PROFILE,IO ,TIME。具体介绍如下:
SET STATISTICS PROFILE ON:显示分析、编译和执行查询所需的时间(以毫秒为单位)。
SET STATISTICS IO ON:报告与语句内引用的每个表的扫描数、逻辑读取数(在高速缓存中访问的页数)和物理读取数(访问磁盘的次数)有关的信息。
SET STATISTICS TIME ON:显示每个查询执行后的结果集,代表查询执行的配置文件。
使用方法:打开SQL SERVER 查询分析器,输入以下语句:
SET STATISTICS PROFILE ON
SET STATISTICS IO ON
SET STATISTICS TIME ON
GO --你的SQL脚本开始
SELECT [LastName] FROM [persons] --自己的SQL语句
GO --你的SQL脚本结束
SET STATISTICS PROFILE OFF
SET STATISTICS IO OFF
SET STATISTICS TIME OFF
使用以上的代码后,会执行得出一个结果显示页面,大家在结果显示里面就能找得相应的答案了.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 5 ms.
(1 row(s) affected)
Table 'sp_UserAssets'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'sp_RealNameAuthentication'. Scan count 1, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'sp_UserInfo'. 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.
(6 row(s) affected)
(1 row(s) affected)
SQL Server Execution Times:
CPU time = 16 ms, elapsed time = 384 ms.
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.
|
上一篇:asp.net获取去掉域名后的本地虚拟路径下一篇:初识Python的下载安装教程(以Python3.5.1为例)
|