22,210
社区成员
发帖
与我相关
我的任务
分享
--建表
create table test
(
id int identity(1,1) primary key,
name varchar(20),
_date datetime
)
--创建存储过程
create proc xxx
as
declare @i int
set @i=1
while @i<700000
begin
insert into test values('xxxx',getdate())
set @i=@i+1
end
--执行。70W的数据。要执行一段时间。
exec xxx
--查询。大约花6秒。
select * from test
--创建索引
create index aaa on test(id)
--再查询。还是6秒。
select * from test
select * from test where id>100000 and id <500000