暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 重建后,索引大小增加了一倍

askTom 2018-03-06
599

问题描述

嗨,

我们为分区表做了索引重建。索引也是分区的。在重建索引之前,索引的大小为170 GB。但是重建后,大小增加了一倍,为327gb。

以下命令使用:

alter index index_name重建分区 _name online parallel 4;

为什么尺寸增加了一倍?我们在这里犯了什么错误吗?请让我知道如何解决这个问题?

谢谢!

专家解答

不能保证重建指数会使其变小。并且很容易构建一个演示,其中重建索引使其更大:

create table t (
  pk not null, stuff not null,
  constraint pk primary key ( pk )
) as
with rws as (
  select level x from dual
  connect by level <= 1000
)
  select rownum pk, lpad('x', 100, 'x') stuff  
  from   rws cross join rws;

exec dbms_stats.gather_table_stats(user, 'T');

select ui.leaf_blocks , us.bytes
from   user_indexes ui
join   user_segments us
on     ui.index_name = us.segment_name
where  ui.index_name = 'PK';

LEAF_BLOCKS   BYTES      
         2088   17825792 

alter session enable parallel ddl;
alter index pk rebuild online parallel 4;

exec dbms_stats.gather_table_stats(user, 'T');

select ui.leaf_blocks , us.bytes
from   user_indexes ui
join   user_segments us
on     ui.index_name = us.segment_name
where  ui.index_name = 'PK';

LEAF_BLOCKS   BYTES      
         2090   17891328 
复制


理查德·富特 (Richard Foote) 在以下位置更详细地讨论了这一点:

https://richardfoote.wordpress.com/2009/01/13/how-to-rebuild-and-make-an-index-bigger-not-smaller-carry-that-weight/

所以错误是希望重建会让指数变小!
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论