首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

到底是什么决定了SQL语句的执行速度,很迷茫解决方法

2012-02-07 
到底是什么决定了SQL语句的执行速度,很迷茫setrowcount900000declare@idvarchar(10)select@ididfromtestt

到底是什么决定了SQL语句的执行速度,很迷茫
set   rowcount   900000
declare   @id   varchar(10)
select   @id=id   from   testtable   order   by   id
print   @id
set   rowcount   10
select   *   from   testtable   where   id   > =   @id   order   by   id
set   rowcount   0  
用时2秒

set   rowcount   100000
declare   @id   varchar(10)
select   @id=id   from   testtable   order   by   id
print   @id
set   rowcount   10
select   *   from   testtable   where   id   > =   @id   order   by   id
set   rowcount   0  
用时8秒

想不通了,取前面的记录反而会慢,SQL   server到底是个什么机制阿?

[解决办法]
你可以看看你的执行计划
两都有什么不同
选中代码:Ctrl+L
[解决办法]
你先执行了100000的那个吧?

热点排行