Home > Database > Mysql Tutorial > SQLSERVER语句的执行时间

SQLSERVER语句的执行时间

WBOY
Release: 2016-06-07 15:44:53
Original
1131 people have browsed it

在SQL语句调优的时候,大部分都会查看语句执行时间,究竟SQLSERVER显示出来的统计结果是什么意思? 下面看一下例子 比较简单的语句: 1 SET STATISTICS TIME ON 2 USE [ pratice ] 3 GO 4 SELECT * FROM [ dbo ] . [ Orders ] 结果: 1 SQL Server 分析和编

在SQL语句调优的时候,大部分都会查看语句执行时间,究竟SQLSERVER显示出来的统计结果是什么意思?

下面看一下例子

比较简单的语句:

<span>1</span> <span>SET</span> <span>STATISTICS</span> TIME <span>ON</span>
<span>2</span> <span>USE</span> <span>[</span><span>pratice</span><span>]</span>
<span>3</span> <span>GO</span>
<span>4</span> <span>SELECT</span> <span>*</span> <span>FROM</span> <span>[</span><span>dbo</span><span>]</span>.<span>[</span><span>Orders</span><span>]</span>
Copy after login


结果:

<span> 1</span> <span>SQL Server 分析和编译时间: 
</span><span> 2</span>    CPU 时间 <span>=</span> <span>0</span> 毫秒,占用时间 <span>=</span> <span>0</span><span> 毫秒。
</span><span> 3</span> 
<span> 4</span> <span>SQL Server 执行时间:
</span><span> 5</span>    CPU 时间 <span>=</span> <span>0</span> 毫秒,占用时间 <span>=</span> <span>0</span><span> 毫秒。
</span><span> 6</span> 
<span> 7</span> <span>SQL Server 执行时间:
</span><span> 8</span>    CPU 时间 <span>=</span> <span>0</span> 毫秒,占用时间 <span>=</span> <span>0</span><span> 毫秒。
</span><span> 9</span> <span>SQL Server 分析和编译时间: 
</span><span>10</span>    CPU 时间 <span>=</span> <span>0</span> 毫秒,占用时间 <span>=</span> <span>0</span><span> 毫秒。
</span><span>11</span> 
<span>12</span> (<span>121317</span><span> 行受影响)
</span><span>13</span> 
<span>14</span> <span>SQL Server 执行时间:
</span><span>15</span>    CPU 时间 <span>=</span> <span>109</span> 毫秒,占用时间 <span>=</span> <span>2506</span> 毫秒。
Copy after login

语句的CPU时间分编译阶段执行阶段。优化者要先搞清楚这两个阶段各用了多少CPU资源。

然后,再看有没有优化降低CPU使用量的可能

上面的CPU时间是指:执行语句的时间

占用时间是指:从磁盘读取数据再处理总的使用时间

编译阶段:

SQL Server 分析和编译时间:

执行阶段:

SQL Server 执行时间:

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template