微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

测试数据 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    实例名

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐