RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
SQLServer数据库测试索引的空间换时间

SQL Server数据库中,我们经常使用索引来提高查询的效率,但是如果索引使用不当就会适得其反。本文我们介绍一种测试索引空间换时间的操作,以方便找到适合利用索引的时机,接下来就让我们一起来了解一下这部分内容吧。

香格里拉网站建设公司创新互联,香格里拉网站设计制作,有大型网站制作公司丰富经验。已为香格里拉上千多家提供企业网站建设服务。企业网站搭建\成都外贸网站建设要多少钱,请找那个售后服务好的香格里拉做网站的公司定做!

 
 
 
  1. create table tb_test(  
  2.        t_id number,  
  3.        t_name nvarchar2(30)  
  4. );  
  5. create sequence seq_tid  
  6. start with 1  
  7. increment by 1  
  8. maxvalue 999999  
  9. minvalue 1  
  10. cache 10 

--项该表中插入99999条记录

 
 
 
  1. begin  
  2.        for n in 1..99999 loop  
  3.            insert into tb_test values(seq_tid.nextval,'1234');  
  4.        end loop;  
  5. end;  
  6. --select count(*) from tb_test;  
  7. --select * from tb_test;  
  8. --select * from tb_test where t_id = 99999; 

--此处以下为测试代码,分别在创建索引和没有创建索引的情况下运行。
--你会发现创建索引后后运行的时间比没有创建索引所需要的时间少很多。

 
 
 
  1. declare  
  2. num number;  
  3. begin  
  4.      for n in 1..9999 loop  
  5.          select t_id into num  from tb_test where t_id=n;  
  6.      end loop;  
  7.      dbms_output.put_line('nunm='||num);  
  8. end; 

--创建对应的索引suncs_space 为自己创建的一个表空间。

 
 
 
  1. create index testid on tb_test(t_id) tablespace suncs_space; 

--删除索引

 
 
 
  1. drop index testid; 

关于SQL Server数据库测试索引的空间换时间的操作就介绍到这里了,希望本次的介绍能够对您有所帮助。


网站题目:SQLServer数据库测试索引的空间换时间
网站网址:http://www.jxjierui.cn/article/djgihgo.html