SQL load direct path load index 无效的原因

2024-04-20 14:44

本文主要是介绍SQL load direct path load index 无效的原因,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Index (unique) state changing to unusable status after data loading using SQL*Loader. The steps below are executed to load the data:

1/ disable constraint--如果不是单独建的index, 对应index会drop掉的
2/ load data using SQL*Loader
3/ remove duplicate records
4/ enable constraint

The execution of step 3 fails due to an index in unusable state:

\n removing duplicate records from the table ... \n
DELETE FROM <TABLE_NAME1> WHERE rowid not in (SELECT MIN(rowid) FROM <TABLE_NAME1> GROUP BY <COLUMN_NAME>)---rowid在期间不能有table move 操作
*
ERROR at line 1:
ORA-01502: index '<INDEX_NAME>_PK' or partition of such index is
in unusable state

Checking the available indexes and their status from dba_indexes, we have:

INDEX_NAMEINDEX_TYPESTATUSTABLE_NAME
<INDEX_NAME>_PKNORMALUNUSABLE<TABLE_NAME1>
<INDEX_NAME>_PKNORMALVALID<TABLE_NAME2>

CHANGES

CAUSE

Some integrity constraints are automatically disabled During a direct path load. The constraints that remain enabled during a direct path load are:

- NOT NULL
- UNIQUE
- PRIMARY KEY (unique-constraints on not-null columns)--PK自动not null

这么说不就是外键 check disable了


- NOT NULL constraints are checked at column array build time. Any row that violates the NOT NULL constraint is rejected.

Even though UNIQUE constraints remain enabled during direct path loads, any row that violates those constraints is loaded anyway (this is different than in conventional path in which such rows would be rejected).
When indexes are rebuilt at the end of the direct path load, UNIQUE constraints are verified and if a violation is detected, then the index will be left in an unusable state.

不拒绝

Indexes Left in an Unusable State
------------------------------------------------
SQL*Loader leaves indexes in an Index Unusable state when the data segment being loaded becomes more up-to-date than the index segments that index it.
Any SQL statement that tries to use an index that is in an Index Unusable state returns an error. The following conditions cause a direct path load to leave an index or a partition of a partitioned index in an Index Unusable state:

  - SQL*Loader runs out of space for the index and cannot update the index.
  - The data is not in the order specified by the SORTED INDEXES clause.
  - There is an instance failure, or the Oracle shadow process fails while building the index.
  - There are duplicate keys in a unique index.
  - Data savepoints are being used, and the load fails or is terminated by a keyboard interrupt after a data savepoint occurred.

Hence this is a expected behavior as:

- Some duplicate rows are getting loaded and indexes are going to unusable state when unique indexes are used.
  - Or -
- SQL*Loader leaves indexes in an Index Unusable state when the data segment being loaded becomes more up-to-date than the index segments that index it.
 

SOLUTION

To overcome the issue:

  • In few cases using conventional path load has resolved the issue.

          - Or -

  • Using normal index instead of unique index will not affect the index status.
  • 先建立普通index 加unique key 控制

          - Or -

  • One can follow below workaround for unique indexes.
  • 本来是个死局,重复的删不了,index不能rebuild,只有drop,

    - Drop the offending index and load the data.
    - Detect duplicate rows
    - Remove the duplicate rows and recreate the index.

这篇关于SQL load direct path load index 无效的原因的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/920543

相关文章

解决mysql插入数据锁等待超时报错:Lock wait timeout exceeded;try restarting transaction

《解决mysql插入数据锁等待超时报错:Lockwaittimeoutexceeded;tryrestartingtransaction》:本文主要介绍解决mysql插入数据锁等待超时报... 目录报错信息解决办法1、数据库中执行如下sql2、再到 INNODB_TRX 事务表中查看总结报错信息Lock

MySQL启动报错:InnoDB表空间丢失问题及解决方法

《MySQL启动报错:InnoDB表空间丢失问题及解决方法》在启动MySQL时,遇到了InnoDB:Tablespace5975wasnotfound,该错误表明MySQL在启动过程中无法找到指定的s... 目录mysql 启动报错:InnoDB 表空间丢失问题及解决方法错误分析解决方案1. 启用 inno

MySQL 安装配置超完整教程

《MySQL安装配置超完整教程》MySQL是一款广泛使用的开源关系型数据库管理系统(RDBMS),由瑞典MySQLAB公司开发,目前属于Oracle公司旗下产品,:本文主要介绍MySQL安装配置... 目录一、mysql 简介二、下载 MySQL三、安装 MySQL四、配置环境变量五、配置 MySQL5.1

MySQL 添加索引5种方式示例详解(实用sql代码)

《MySQL添加索引5种方式示例详解(实用sql代码)》在MySQL数据库中添加索引可以帮助提高查询性能,尤其是在数据量大的表中,下面给大家分享MySQL添加索引5种方式示例详解(实用sql代码),... 在mysql数据库中添加索引可以帮助提高查询性能,尤其是在数据量大的表中。索引可以在创建表时定义,也可

Mybatis Plus JSqlParser解析sql语句及JSqlParser安装步骤

《MybatisPlusJSqlParser解析sql语句及JSqlParser安装步骤》JSqlParser是一个用于解析SQL语句的Java库,它可以将SQL语句解析为一个Java对象树,允许... 目录【一】jsqlParser 是什么【二】JSqlParser 的安装步骤【三】使用场景【1】sql语

MySQL 存储引擎 MyISAM详解(最新推荐)

《MySQL存储引擎MyISAM详解(最新推荐)》使用MyISAM存储引擎的表占用空间很小,但是由于使用表级锁定,所以限制了读/写操作的性能,通常用于中小型的Web应用和数据仓库配置中的只读或主要... 目录mysql 5.5 之前默认的存储引擎️‍一、MyISAM 存储引擎的特性️‍二、MyISAM 的主

Linux lvm实例之如何创建一个专用于MySQL数据存储的LVM卷组

《Linuxlvm实例之如何创建一个专用于MySQL数据存储的LVM卷组》:本文主要介绍使用Linux创建一个专用于MySQL数据存储的LVM卷组的实例,具有很好的参考价值,希望对大家有所帮助,... 目录在Centos 7上创建卷China编程组并配置mysql数据目录1. 检查现有磁盘2. 创建物理卷3. 创

MySQL 事务的概念及ACID属性和使用详解

《MySQL事务的概念及ACID属性和使用详解》MySQL通过多线程实现存储工作,因此在并发访问场景中,事务确保了数据操作的一致性和可靠性,下面通过本文给大家介绍MySQL事务的概念及ACID属性和... 目录一、什么是事务二、事务的属性及使用2.1 事务的 ACID 属性2.2 为什么存在事务2.3 事务

Mysql中的用户管理实践

《Mysql中的用户管理实践》:本文主要介绍Mysql中的用户管理实践,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录13. 用户管理13.1 用户 13.1.1 用户信息 13.1.2 创建用户 13.1.3 删除用户 13.1.4 修改用户

MySQL查看表的最后一个ID的常见方法

《MySQL查看表的最后一个ID的常见方法》在使用MySQL数据库时,我们经常会遇到需要查看表中最后一个id值的场景,无论是为了调试、数据分析还是其他用途,了解如何快速获取最后一个id都是非常实用的技... 目录背景介绍方法一:使用MAX()函数示例代码解释适用场景方法二:按id降序排序并取第一条示例代码解