DBAtlas · 数据库运维图谱

在线重建索引

Oracle维护

命令

-- Regular index:
ALTER INDEX customer_app.idx_customer_email REBUILD ONLINE PARALLEL 4;

-- Moving it to a different tablespace:
ALTER INDEX customer_app.idx_customer_email
  REBUILD ONLINE TABLESPACE customer_idx PARALLEL 4;

-- Reset parallelism after the rebuild (so plans are not affected):
ALTER INDEX customer_app.idx_customer_email NOPARALLEL;

作用

在不阻塞 DML 的情况下重建索引(ONLINE);消除碎片,并可更换表空间。

适用场景

索引膨胀/碎片、将索引迁移到其他表空间、修复 UNUSABLE 索引。

注意

ONLINE 会使用额外的临时空间和 I/O。PARALLEL 设置会保留;重建后用 NOPARALLEL 重置,否则查询会意外并行执行。并非所有版本的位图索引都支持 ONLINE。ONLINE 重建仅在 Enterprise Edition 中可用。

在 DBAtlas 中打开 →

相关内容