在Oracle 12c (12.1)中,我们有一个带有间隔分区的大型分区表。除了本地索引之外,它还有两个全局索引。删除带有UPDATE子句的旧分区有助于全局索引保持有效。
第二天晚上,名为异步全局索引维护后台作业的特性启动了一个ALTER INDEX xxx COALESCE CLEANUP命令,该命令在几天后运行,并从删除分区的孤立条目中清除全局索引。
不幸的是,我们需要用不同的参数在这个表上创建另一个索引,但是由于后台作业导致的共享DML锁(Row-X (SX)),这是不可能的。因为我们需要部署一个新版本,所以我们肯定需要另一个索引上的DDL。对我来说这看起来很奇怪,改变索引..。合并清理不允许并行创建另一个索引。为什么要有关系呢?
问:如果会议结束,过去两天的工作会不会丢失,工作需要从头再开始?
发布于 2020-04-21 21:05:35
由于明显的原因(懒惰),我用这个例子来创建这个帖子中的表和索引:
create table muse (id number, code number, name varchar2(30)) partition by range (id) (partition muse1 values less than (1000001), partition muse2 values less than (2000001), partition muse3 values less than (maxvalue));
insert into muse with g as (select * from dual connect by level <= 1000) select rownum, mod(rownum,100000), 'DAVID BOWIE' from g,g,g where rownum <= 3000000;
commit;
create index muse_id_i on muse(id);
create index muse_code_i on muse(code) global partition by range(code)(partition code_p1 values less than (50000), partition code_p2 values less than (maxvalue));
exec dbms_stats.gather_table_stats(ownname=>user, tabname=>'MUSE', cascade=>true, estimate_percent=>null, method_opt=>'FOR ALL COLUMNS SIZE 1');接下来,删除一个分区:
SQL> alter table muse drop partition muse1 update global indexes;
Table altered.然后分析指数:
SQL> analyze index muse_id_i validate structure;
Index analyzed.
SQL> select name, lf_rows, del_lf_rows from index_stats;
NAME LF_ROWS DEL_LF_ROWS
------------------------------ ---------- -----------
MUSE_ID_I 3000000 1000000孤立条目在这里显示为已删除的条目。
我的加注来了。手动启动coalesce cleanup,然后在几秒钟内中断它(Ctrl),然后再次分析索引:
SQL> alter index muse_id_i coalesce cleanup;
^C
alter index muse_id_i coalesce cleanup
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation
SQL> SQL> analyze index muse_id_i validate structure;
Index analyzed.
SQL> select name, lf_rows, del_lf_rows from index_stats;
NAME LF_ROWS DEL_LF_ROWS
------------------------------ ---------- -----------
MUSE_ID_I 2723063 723063如您所见,即使中断了命令,也清理了一些条目。现在再做一次:
SQL> alter index muse_id_i coalesce cleanup;
^Calter index muse_id_i coalesce cleanup
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation
SQL> analyze index muse_id_i validate structure;
Index analyzed.
SQL> select name, lf_rows, del_lf_rows from index_stats;
NAME LF_ROWS DEL_LF_ROWS
------------------------------ ---------- -----------
MUSE_ID_I 2532434 532434接下来创建一个索引,然后继续:
SQL> create index muse_name_i on muse(name) local;
Index created.
SQL> alter index muse_id_i coalesce cleanup;
^C
alter index muse_id_i coalesce cleanup
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation
SQL> SQL> analyze index muse_id_i validate structure;
Index analyzed.
SQL> select name, lf_rows, del_lf_rows from index_stats;
NAME LF_ROWS DEL_LF_ROWS
------------------------------ ---------- -----------
MUSE_ID_I 2151894 151894最后:
SQL> alter index muse_id_i coalesce cleanup;
Index altered.
SQL> analyze index muse_id_i validate structure;
Index analyzed.
SQL> select name, lf_rows, del_lf_rows from index_stats;
NAME LF_ROWS DEL_LF_ROWS
------------------------------ ---------- -----------
MUSE_ID_I 2000000 0
SQL>所以不,进度并没有消失。
https://dba.stackexchange.com/questions/265489
复制相似问题