ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 百萬行數據查詢性能比較

百萬行數據查詢性能比較

原创 Linux操作系统 作者:keeking 时间:2009-08-03 10:35:37 0 删除 编辑

----------------------該方案37秒加5秒
set nocount on
if object_id('dbo.Nums')is not null
drop table dbo.Nums;
go
create table dbo.Nums ( n int not null primary key)
declare @max as int,@rc as int
set @max=1000000
set @rc=1

insert into Nums values(1)
while @rc*2<=@max
begin
insert into dbo.Nums select n+@rc from dbo.Nums
set @rc=@rc*2;
end

insert into dbo.Nums
select n+@rc from dbo.Nums where =@n
option (maxrecursion 0)

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7899089/viewspace-611115/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 自復制代碼
请登录后发表评论 登录
全部评论

注册时间:2009-07-23

  • 博文量
    194
  • 访问量
    287359