select top 1000 id=identity(int,1,1),1 col into # from sysobjects,syscolumns
set statistics time on
update # set col=col+1 where id<=1000
set statistics time off
drop table #SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 4 毫秒。(1000 行受影响)
set statistics time on
update # set col=col+1 where id<=1000
set statistics time off
drop table #SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 4 毫秒。(1000 行受影响)
解决方案 »
- 如何查询表中某条记录的插入,及更新时间?
- 在C#中的SQL语句中如何直接使用C#程序中定义的整型变量@x。能这样"select * from A where M=@x"使用@x吗?那么,如何使用@x?请不要说这样使用@x:"select * from A where M="+@x
- 重复记录 ; distinct ;Text类型 的问题
- SQL SERVER 2000中如何实现行级的排他锁?
- 再问inner join和left join
- 请教SQL问题
- 事务的回滚
- 无法创建链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 的实例
- 怎么安装java需要专用的sqlserver驱动,那里有下载
- 我用DTS导入视图,结果都变成了表,请问各位如何导视图(只是视图)?
- 复杂的SQL,请大家帮忙
- apriori算法扫描数据库的最佳方案
set statistics time on
update # set col=col+1
set statistics time off
drop table #/*
SQL Server 执行时间:
CPU 时间 = 15 毫秒,占用时间 = 3 毫秒。(1000 行受影响)
*/
--看看下面的两个时间差,就知道你用了多少时间。
select getdate()
update tb set col=1
select getdate()
但是,他的意思好像是,限定300毫秒之内,更新1000条记录。
有些update是很费时间的,如果超过300毫秒,该怎么办?
如果只考虑Update的效率,可以考虑根据where 出现的列上建立簇索引,
保证数据存在相邻的数据页上。
300毫秒能否更新完,跟硬件、锁、系统压力等状况,有很大关系。