首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >中断ALTER合并清理到目前为止是否丢失了工作?

中断ALTER合并清理到目前为止是否丢失了工作?
EN

Database Administration用户
提问于 2020-04-21 09:40:24
回答 1查看 2.1K关注 0票数 2

在Oracle 12c (12.1)中,我们有一个带有间隔分区的大型分区表。除了本地索引之外,它还有两个全局索引。删除带有UPDATE子句的旧分区有助于全局索引保持有效。

第二天晚上,名为异步全局索引维护后台作业的特性启动了一个ALTER INDEX xxx COALESCE CLEANUP命令,该命令在几天后运行,并从删除分区的孤立条目中清除全局索引。

不幸的是,我们需要用不同的参数在这个表上创建另一个索引,但是由于后台作业导致的共享DML锁(Row-X (SX)),这是不可能的。因为我们需要部署一个新版本,所以我们肯定需要另一个索引上的DDL。对我来说这看起来很奇怪,改变索引..。合并清理不允许并行创建另一个索引。为什么要有关系呢?

问:如果会议结束,过去两天的工作会不会丢失,工作需要从头再开始?

EN

回答 1

Database Administration用户

回答已采纳

发布于 2020-04-21 21:05:35

由于明显的原因(懒惰),我用这个例子来创建这个帖子中的表和索引:

https://richardfoote.wordpress.com/2013/08/02/12c-asynchronous-global-index-maintenance-part-i-where-are-we-now/

代码语言:javascript
复制
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');

接下来,删除一个分区:

代码语言:javascript
复制
SQL> alter table muse drop partition muse1 update global indexes;

Table altered.

然后分析指数:

代码语言:javascript
复制
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),然后再次分析索引:

代码语言:javascript
复制
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

如您所见,即使中断了命令,也清理了一些条目。现在再做一次:

代码语言:javascript
复制
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

接下来创建一个索引,然后继续:

代码语言:javascript
复制
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

最后:

代码语言:javascript
复制
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>

所以不,进度并没有消失。

票数 3
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/265489

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档