alter index rebuild & alter index rebuild online

---转摘自:http://blog.chinaunix.net/u/10516/showart_1009036.html
收藏学习
 
alter index rebuild与alter index rebuild online的扫描方式是不一样的。可以举个简单的例子来说明:
SQL>create table sjh.test as select * from dba_users;  --建一个测试表
SQL> explain plan for
  2  alter index test_idx rebuild;
Explained
SQL>  select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 2554748275
--------------------------------------------------------------------------------
| Id  | Operation              | Name     | Rows  | Bytes | Cost (%CPU)| Time
--------------------------------------------------------------------------------
|   0 | ALTER INDEX STATEMENT  |          |   327 |  4251 |     1   (0)| 00:00:0
|   1 |  INDEX BUILD NON UNIQUE| TEST_IDX |       |       |            |
|   2 |   SORT CREATE INDEX    |          |   327 |  4251 |            |
|   3 |    INDEX FAST FULL SCAN| TEST_IDX |   327 |  4251 |     1   (0)| 00:00:0
--------------------------------------------------------------------------------
10 rows selected
SQL> explain plan for
  2  alter index test_idx rebuild online;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1149508270
--------------------------------------------------------------------------------
| Id  | Operation              | Name     | Rows  | Bytes | Cost (%CPU)| Time
--------------------------------------------------------------------------------
|   0 | ALTER INDEX STATEMENT  |          |   327 |  4251 |     1   (0)| 00:00:0
|   1 |  INDEX BUILD NON UNIQUE| TEST_IDX |       |       |            |
|   2 |   SORT CREATE INDEX    |          |   327 |  4251 |            |
|   3 |    TABLE ACCESS FULL   | TEST     |   327 |  4251 |     1   (0)| 00:00:0
--------------------------------------------------------------------------------
10 rows selected
SQL>
 
--从上面例子红色标签位置可以很清楚的看到 index rebuild online实质上是扫描表而不是扫描现有的索引块来实现索引的重建,index rebuild 只扫描现有的索引块来实现索引的重建。
 
除了扫描方式不同外,rebuild 会阻塞dml语句而rebuild online则不会(ddl语句除外)。
rebuild online时系统会产生一个SYS_JOURNAL_xxx的IOT类型的系统临时日志表,所有rebuild online时索引的变化都记录在这个表中(但要使用两倍于传统方法的空间),当新的索引创建完成后,把这个表的记录维护到新的索引中去,然后drop掉旧的索引,rebuild online就完成了。
注意并行处理,DDL,位图索引不能使用ONLINE。
 
在rebuild online 时会报错:
ORA-08120: Need to create SYS.IND_ONLINE$ table in order to (re)build index
Cause: Alter index Build/Rebuild online require existing of SYS.IND_ONLINE$ table.
Action: User/DBA needs to create sys.ind_online$ before alter the index /rdbms/admin/catcio.sql contains script. to create ind_online$.

解决方法就是运行catcio.sql 创建SYS.IND_ONLINE$表

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10173379/viewspace-629719/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10173379/viewspace-629719/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值