问题描述
请教一个问题:500g一个表,想要删除一个global index 创建一个local index。有没有办法可以比较准确的评估出创建local index的时间的?
专家解答
unusable创建,online rebuild一个历史分区评估一下时间
--1. 先创建unusable invisible local index (因为rebuild过程没有global统计信息,先invisible)
--这一步很快,基本上不需要时间:
create index &idx_name on &tab_name(col1,col2 )
local unusable invisible tablespace (&tbs_name);
--2. 逐个分区rebuild local index(适当加一点并行) ,online 和 nologging,根据需要:
select 'alter index '||c.index_name||' rebuild partition ' || c.partition_name || ' parallel(degree 4) online nologging;'
from dba_ind_partitions c where index_name=upper('&idx_name') and status != 'USABLE';
--上面sql生成的结果,逐个执行! 也可以在多个session同时执行,并发数量不宜太多
--3.收集索引上的global 统计信息(重要!):
exec dbms_stats.gather_index_stats('&owner','&idx_name',degree=>8 ,force=>true);
--4. 去掉索引并行属性:
alter index &idx_name noparallel;
--5. 使索引可见:
alter index &idx_name visible;
另外,12c 可以多索引共存的,所以不需要删除老的,直接可以创建一个不可见的local索引,加上online和并行就好。创建结束后,找个低峰时期把global和local的可见属性互换一下就可以了。

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




