日期:2014-05-16  浏览次数:20492 次

续《表扫描与索引扫描返回的行数不一致》

续《表扫描与索引扫描返回的行数不一致》


上篇文章主要介绍了如何从分析表得到的报错,以及trace中的信息,判断表返回的记录与索引返回记录不一致时的处理方式。下面这篇文章则介绍了针对ORA-1499进行问题排查的一些基本方法。


OERR: ORA-1499 table/Index Cross Reference Failure - see trace file (文档 ID 1499.1)


Error: ORA 1499
Text: table/Index Cross Reference Failure - see trace file
-------------------------------------------
Cause:  An error occurred when validating an index or a table using the
        ANALYZE command.
        One or more entries does not point to the appropriate cross-reference.
Action: Check the trace file for more descriptive messages about the problem.
        Correct these errors.


ORA-1499的错误是通过“"ANALIZE TABLE|CLUSTER <name> VALIDATE STRUCTURE CASCADE”分析得出的,它的含义是表或聚类和索引之间存在不一致性,具体来讲是索引键值未出现在索引中,或者相反。


trace文件中包含:

<description>: tsn: <tablespace number> rdba: <relative dba>

description有以下值:

"row not found in index" 
"Table/Index row count mismatch"
"row mismatch in index dba"
"Table row count/Bitmap index bit count mismatch"
"kdavls: kdcchk returns %d when checking cluster dba 0x%08lx objn %d\n"

tsn:    Tablespace Number表示的是索引存储的表空间编号。

rdba: 是索引段头相对于数据块的存储地址。


SQL> analyze table DEPT validate structure cascade;
analyze table case7 validate structure cascade
*
ERROR at line 1:
ORA-01499: table/index cross reference failure - see trace file


trace文件的实例:

row not found in index tsn: 5 rdba: 0x02c00061


哪些索引受影响?
包含ORA-1499的trace文件提供了与索引相关的段头rdba。查询dba_segments来明确索引:
SELECT owner, segment_name, segment_type, partition_name
FROM   DBA_SEGMENTS
WHERE  header_file = (SELECT file#
                                          FROM   v$datafile
                                          WHERE  rfile# = dbms_utility.data_block_address_file(to_number('&rdba','XXXXXXXX'))
                          &nbs