AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 265489
Accepted
D. Lohrsträter
D. Lohrsträter
Asked: 2020-04-22 01:40:24 +0800 CST2020-04-22 01:40:24 +0800 CST 2020-04-22 01:40:24 +0800 CST

到目前为止,中断 ALTER INDEX COALESCE CLEANUP 是否会丢失工作?

  • 772

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

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

不幸的是,我们需要在这个表上创建另一个具有不同参数的索引,但是由于后台作业导致的共享 DML 锁 (Row-X (SX)) 导致资源繁忙错误,这是不可能的。由于我们需要部署一个新版本,我们肯定需要另一个索引上的 DDL。对我来说,这看起来很奇怪, alter index ... coalesce cleanup 不允许并行创建另一个索引。为什么要有关系?

问题:如果我们杀死会话,过去2天的工作会丢失,工作需要从头重新开始吗?

oracle index
  • 1 1 个回答
  • 1575 Views

1 个回答

  • Voted
  1. Best Answer
    Balazs Papp
    2020-04-22T13:05:35+08:002020-04-22T13:05:35+08:00

    出于明显的原因(懒惰),我使用示例从这篇文章中创建表和索引:

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

    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-C),然后再次分析索引:

    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>
    

    所以不,进步并没有丢失。

    • 3

相关问题

  • 如何在数据库中找到最新的 SQL 语句?

  • 如何使用正则表达式查询名称?

  • 我在索引上放了多少“填充”?

  • RDBMS 上的“索引”是什么意思?[关闭]

  • 如何在 MySQL 中创建条件索引?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve