纸上得来终觉浅,绝知此事要躬行

读书笔记之-索引压缩

上一篇 / 下一篇  2008-04-21 13:42:05 / 个人分类:读书笔记

1. 创建一个索引组织表,但不压缩

sys@TEST>createtable iot                                                                   
  2  (owner,object_type,object_name,
  3  constraint iot_pk primary key(owner,object_type,object_name)
  4  )
  5  organization index
  6  nocompress
  7  as 
  8  select distinct owner,object_type,object_name         
  9  from sys.all_objects;
 
Table created.
 
sys@TEST>selectcount(*) from iot;
 
  COUNT(*)
----------
      2820
 
sys@TEST>analyzeindex iot_pk validate structure;
 
Index analyzed.
 
sys@TEST>selectlf_blks,br_blks,used_space,opt_cmpr_count,opt_cmpr_pctsave from index_stats;
 
   LF_BLKS    BR_BLKS USED_SPACE OPT_CMPR_COUNT OPT_CMPR_PCTSAVE
---------- ---------- ---------- -------------- ----------------
        14          1      94125              2               37

可见,这个未压缩的索引使用了14个叶子块,1个分支块,使用空间为94125字节。另外,建议的最优压缩数为2.

2 。将表重建,并指定compress 为1.
 
sys@TEST>altertable iot move compress 1;
 
Table altered.
 
sys@TEST>selectlf_blks,br_blks,used_space,opt_cmpr_count,opt_cmpr_pctsave from index_stats;
 
no rows selected
 
sys@TEST>analyzeindex iot_pk validate structure;
 
Index analyzed.
 
sys@TEST>selectlf_blks,br_blks,used_space,opt_cmpr_count,opt_cmpr_pctsave from index_stats;
 
   LF_BLKS    BR_BLKS USED_SPACE OPT_CMPR_COUNT OPT_CMPR_PCTSAVE
---------- ---------- ---------- -------------- ----------------
        11          1      78121              2               24

可见,压缩数为1时,使用的叶子块为11个,占用空间78121字节,得到了压缩。

3. 再次重建这个表,压缩数指定为2.
 
sys@TEST>altertable iot move compress 2;
 
Table altered.
 
sys@TEST>analyzeindex iot_pk validate structure;
 
Index analyzed.
 
sys@TEST>selectlf_blks,br_blks,used_space,opt_cmpr_count,opt_cmpr_pctsave from index_stats;
 
   LF_BLKS    BR_BLKS USED_SPACE OPT_CMPR_COUNT OPT_CMPR_PCTSAVE
---------- ---------- ---------- -------------- ----------------
         9          1      58864              2                0
 

可见,此时索引得到了最大压缩,只剩下9个叶子块,占用空间58864字节。


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-09-07  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 1601
  • 日志数: 67
  • 图片数: 2
  • 影音数: 1
  • 建立时间: 2008-02-29
  • 更新时间: 2008-09-06

RSS订阅

Open Toolbar