添加索引
IF EXISTS (SELECT name FROM sysindexes
          WHERE name = 'IX_writtenExam')
   DROP INDEX testtable.IX_writtenExam
/*--笔试列创建非聚集索引:填充因子为%--*/
CREATE NONCLUSTERED INDEX IX_writtenExam
     ON testtable(id)
          WITH FILLFACTOR= 30
GO

查询测试
/*-----指定按索引IX_writtenExam 查询----*/
declare @startTime datetime
SET @startTime = GETDATE();
SELECT sum(ID) FROM testtable with (INDEX=IX_writtenExam)
declare @endtime datetime
SET @endtime = GETDATE();
print datediff(ms,@startTime,@endtime)

SELECT sum(ID) FROM testtable

添加数据
SET IDENTITY_INSERT TestTable ON
declare @i int
set @i=1
while @i<=400000
begin
    insert into TestTable([id], FirstName, LastName, Country,Note) values(@i, 'FirstName_XXX','LastName_XXX','Country_XXX','Note_XXX')
    set @i=@i+1
end
SET IDENTITY_INSERT TestTable OFF

相关文章:

  • 2021-08-14
  • 2021-11-14
  • 2021-08-05
  • 2022-12-23
  • 2021-12-11
  • 2021-07-30
  • 2022-03-10
猜你喜欢
  • 2022-12-23
  • 2021-09-12
  • 2021-08-19
  • 2021-07-19
  • 2021-12-05
  • 2021-10-24
相关资源
相似解决方案