易截截图软件、单文件、免安装、纯绿色、仅160KB

Sql Server 2005 row_number()分页性能测试

  现在分页方法大多集中在select top/not in/游标/row_number,而select top分页(在这基础上还有二分法)方法似乎更受大家欢迎,这篇文章并不打算去讨论是否通用的问题,本着实用的原则,花了一些时间去测试row_number()分页的性能,感觉并不像一部分人所说的那么鸡肋,由于接触软件开发才十个月,方方面面的东西都要学,经验实在有限,不足之处请原谅,测试如下:
平台与环境:
CPU:AMD 1150 2G 单核
内存:1G(系统正常启动后约占300M空间)
硬盘:SATA 160G 8M Cache
系统:windows 2003 ent+Sql Server 2005 sp2
数据:共500万条
-------------------------------------------------------------------
测试数据:
create table test_table
(
id   int identity(1,1) primary key not null,
cid   int  not null,
userName  varchar(50) null,
userPwd   varchar(50) null,
createTime datetime null
)
---------------------------------------------------------------------
插入记录(cid分别插入1,2,3,4,机器实在太慢,总共只插入500万条):
declare @count int
set @count=1
while @count<=1000000
begin
insert into test_table(cid,userName,userPwd,createTime) values(2,'admin','admin888',getdate())
set @count=@count+1
end
-------------------------------------------------------------------------------------------------------
分页测试代码:
这里采用row_number的两种分页方式:分别用top和between过滤
/*row_number() 查询方法一*/
declare @tdiff datetime
set @tdiff=getdate()
select top 20 * from(select row_number() over(order by createtime desc,id asc) as rownumber,* from test_table ) as tb where rownumber>120000
select datediff(ms,@tdiff,getdate()) as '耗时(毫秒)'
/*row_number() 查询方法二*/
declare @tdiff datetime 
set @tdiff=getdate()
select * from(select row_number() over(order by createtime desc,id asc) as rownumber,* from test_table ) as tb where rownumber between 120000 and 120200
select datediff(ms,@tdiff,getdate()) as '耗时(毫秒)'
----------------------------------------------------------------------------------------------------------
测试方法及结果(取


相关文档:

航空公司管理系统(VC++ 与SQL 2005)

系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
      这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......

SQL中EXISTS的用法


比如在Northwind数据库中  
  有一个查询为  
  SELECT   c.CustomerId,   CompanyName  
  from   Customers   c  
  WHERE   EXISTS(  
              SELECT   OrderID   from   ......

使用Oracle sql_trace 工具

前言:
    sql_trace 是我在工作中经常要用到的调优工具,相比较statspack 我更愿意用这个工具。
    因为数据库慢原因的85%以上是由于sql问题造成的,statspack没有sql的执行计划。显示没有它直观,方便,对想要针对性不强,
    1,介绍数据库调优需要经常会用到的工具 ......

SQL 语言

SQL操作全集
下列语句部分是Mssql语句,不可以在access中使用。
SQL分类:
DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE)
DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT)
DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)
首先,简要介绍基础语句:
1、说明:创建数据库
CREATE ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号