oracle index unusable

1,应用人员反应:
某数据库T_TABLE_XX_15表,没有做任何处理,索引还在,
但查询慢,影响历史查询,影响应用服务器,体现在界面操作慢


。select * from T_TABLE_XX_15 a where a.order_id ='101505103 ';


2, 登记查看

##执行计划确实是全表

扫描set autotrace traceonly explain;
select * from USERXX.T_TABLE_XX_15 a where a.order_id ='101505103';
执行计划
------------------------------------------------ ----------
计划哈希值:3479521290


----------------------------------- -------------------------------------------------- ------
| Id | 操作| 名称| 行| Bytes | 成本(%CPU)| 时间|
-------------------------------------------------- -----------------------------------------
| 0 | SELECT STATEMENT | | 25 | 2225 | 4494K(1)| 14:58:52 |
| * 1 | TABLE ACCESS FULL | T_TABLE_XX_15 | 25 | 2225 | 4494K(1)| 14:58:52 |
-------------------------------------------------- -----------------------------------------


##表情况
SELECT T.TABLE_NAME, T.LAST_ANALYZED,NUM_ROWS,AVG_ROW_LEN,T.PARTITIONED,T.TABLESPACE_NAME,CEIL(S.BYTES / 1048576)MB
FROM DBA_TABLES T,DBA_SEGMENTS S
WHERE T.OWNER ='USERXX'AND T.TABLE_NAME IN 
('T_TABLE_XX_15')
AND S.OWNER = T.OWNER AND S.SEGMENT_TYPE ='TABLE'AND S.SEGMENT_NAME(+)= T.TABLE_NAME
ORDER BY 1;


TABLE_NAME LAST_ANALYZE NUM_ROWS AVG_ROW_LEN PAR TABLESPACE_NAME MB
------------------------------ ------------ - --------- ----------- --- --------------------------- --- ----------
T_TABLE_XX_15 27-DEC-16 1434934004 89否BASE_USERXX 32568


##索引情况
SET页100行132
COL COLUMN_NAME FOR A20
COL POS FOR 999
SELECT I.TABLE_NAME,I.INDEX_NAME, I.STATUS,C.COLUMN_NAME,C.COLUMN_POSITION AS POS, 
SUBSTRB(I.UNIQUENESS,1,1)AS U,I.PARTITIONED
FROM DBA_INDEXES我,DBA_IND_COLUMNS?
WHERE I.TABLE_OWNER ='USERXX'AND I.TABLE_NAME IN 
( 'T_TABLE_XX_15')
AND C.TABLE_OWNER = I.TABLE_OWNER AND C.TABLE_NAME = I.TABLE_NAME AND C.INDEX_NAME = I.INDEX_NAME
ORDER BY 1,2,4;


TABLE_NAME INDEX_NAME STATUS COLUMN_NAME POS U PAR
------------------------------ ------------- ----------------- -------- -------------------- ---- - ---
T_TABLE_XX_15 SYS_C00452863 UNUSABLE APPLY_ID 1 U NO
T_TABLE_XX_15 SYS_C00452863不可用标志5 U无
T_TABLE_XX_15 SYS_C00452863 UNUSABLE ORDER_ID 2 U无
T_TABLE_XX_15 SYS_C00452863 UNUSABLE P_SEQ 4 U无
T_TABLE_XX_15 SYS_C00452863 UNUSABLE INST_ID 3 U无命令


大小:
SQL> select sum(bytes) / 1024/1024 from dba_segments其中segment_name ='SYS_C00452863';


SUM(BYTES)/
1024/1024 --------------------
              106970


##确认索引状态是UNUSABLE,即不可用:
select / * + INDEX(a SYS_C00452863) * / * from USERXX.T_TABLE_XX_15 a where a.order_id ='101505103';
错误在第1行:
ORA-01502:索引'USERXX.SYS_C00452863'或这种索引的分区处于不可用状态

##扩用户临时表空间到40GB:
alter tablespace TMP_USERXX添加tempfile'/ dev / rdblv187'size 8190m;
alter tablespace TMP_USERXX add tempfile'/ dev / rdblv188'size 8190m;
alter tablepace TMP_USERXX add tempfile'/ dev / rdblv189'size 8190m;


创建新索引(只针对字段ORDER_ID)
在T_TABLE_XX_15(ORDER_ID)上创建索引T_TABLE_XX_15_01表空间INDX_USERXX;


SQL> select sum(bytes)/ 1024/1024/1024 from dba_segments where segment_name ='T_TABLE_XX_15_01';
SUM(BYTES)/
1024/1024/1024
                ------------------------- 32.234375
                
##索引知识点:
#set autotrace traceonly explain;
alter index index_name enable;
alter index index_name disable;
alter index index_name不可用;
alter index index_name rebuild;
alter index index_name不可见;
alter index index_name visible;


启用/禁用针对函数索引。
不可用的索引是被优化器所忽略,并且不被dml操作维护,如果索引被不可用后,需要重建
。invisible索引被忽略,但是dml操作仍然会维护索引。 11g新特性)  


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27126919/viewspace-2135154/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27126919/viewspace-2135154/

你可能感兴趣的:(oracle index unusable)