您的位置:首页 > 数据库

SqlServer2005 分页语句,自己简单测试了,感觉速度很快,就记录下来了,便于以后学习。

2010-06-21 21:36 417 查看
测试数据 2359296 条记录

select *
from (
select row_number() over ( order by tempColumn) tempRowNumber,*
from ( select top 2359296 tempColumn= 0,* from table order by id) t
) tt
where tempRowNumber> 2359286

SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 1 毫秒。

(10 行受影响)

SQL Server 执行时间:
CPU 时间 = 1000 毫秒,占用时间 = 1012 毫秒。

========================================================================================

select top 10 * from boao
where id>( select max (id )
from ( select top 2359286 id from table order by id) tt)

测试结果:

SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 1 毫秒。

(10 行受影响)

SQL Server 执行时间:
CPU 时间 = 5952 毫秒,占用时间 = 6812 毫秒

========================================================================================

select top 10 * from table
where table not in( select top 2359286 id from table )

SQL Server 分析和编译时间:
CPU 时间 = 0 毫秒,占用时间 = 1 毫秒。

(10 行受影响)

SQL Server 执行时间:
CPU 时间 = 6469 毫秒,占用时间 = 6523 毫秒。

在论坛看见朋友们测试了,第二条SQL语句比第三条SQL要快,但是在我这不知道怎么回事 这两条SQL语句的速度
差不错,晕了,我也反复测试了好多次呢,希望大家有时间测试下哈,小弟才疏学浅只是简单的测试下,希望大家多多指教。

set statistics time on--打开时间
set statistics time off--关闭时间
select @@servername 实例名
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐