行添加和集合化添加数据后台的数据日志变化

来源:互联网 发布:ip爬虫软件 编辑:程序博客网 时间:2024/05/22 18:39
use testif object_id('tw') is not null drop table twcreate table tw(i int)
--第一种方法 日志多,运行快dbcc sqlperf(logspace)declare @i intset @i=1begin transactionwhile @i<=10000 begin insert into tw(i) values(@i/256) select @i=@i+1 endcommitdbcc sqlperf(logspace)--第二种方法 日志少,运行慢dbcc sqlperf(logspace)select top 10000 a.id into #ta from sys.sysobjects a join sys.sysobjects b on 1=1begin transactioninsert into tw(i)select * from #tacommitdrop table #tadbcc sqlperf(logspace)
--数据比较--1、行集添加数据日志变化TEST 109.7422 4.011978TEST 109.7422 4.864028--2、增加集合化添加数据日志变化TEST 109.7422 4.864028TEST 109.7422 5.192835
--结果分析select 4.864028-4.011978,5.192835-4.864028--------------------------------------- ---------------------------------------0.852050                                0.328807
附加说明
但是要注意一点,在日志中包含太多的数据操纵查询,事务的持续时间将加长在这时候,所有试图访问事务中引用的资源的其他查询将被阻塞