到底是什么决定了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的那个吧?