SQL Server中,测试插入大量数据,执行时间。
declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()
declare @counter int
set @counter=0
while(@counter < 1000000)
begin
INSERT INTO testsql.dbo.Errorlog VALUES(''+@counter+'','b','c','d','e','f')
set @counter=@counter + 1
end
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用时/毫秒'
--1====3
--10====3
--100===20
--1000===300
--10000===2490
--100000===30000
--1000000===328936
--10000000===
--29513
--31416
--30066
--30066
--31326
declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()
select COUNT(tid) from errorlog
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用时/毫秒'