skip_unusable_indexes
关于参数 skip_unusable_indexes :
在 9i中 这个参数是 session级默认是 false ,10g中 该参数被调整为系统级,同时默认为 true ,顾名思义就是会跳过不可用的索引,避免ORA-01502错误,提高系统的可用性,但是会牺牲系统的性能。
注意:即使该参数值为 true 时 ,仍然不能避免 查询中 使用 hints 去走索引而报索引不可用的错,详细请看以下测试:
查看 9i 和 10g中此参数的设置:
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as justone5
SQL> show parameter skip
NAME TYPE VALUE
------------------------------------ -----------
skip_unusable_indexes boolean TRUE
Connected to Oracle9i Enterprise Edition Release 9.2.0.8.0
Connected as justone4
SQL> show parameter skip
10g中该参数的影响
-------------i am split----------------------------------------------
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as justone5
SQL> show parameter skip
NAME TYPE VALUE
------------------------------------ -----------
skip_unusable_indexes boolean TRUE
SQL> create table test_a(a number);
Table created
SQL> create index idx_test_a on test_a(a);
Index created
SQL> insert into test_a select rownum from dba_objects where rownum <1000;
999 rows inserted
SQL> commit;
Commit complete
SQL> alter index idx_test_a unusable;
Index altered
SQL> select * from test_a where a=1;
A
----------
1
SQL> alter system set skip_unusable_indexes=false;
System altered
SQL> select * from test_a where a=1;
select * from test_a where a=1
ORA-01502: 索引 'JUSTONE5.IDX_TEST_A' 或这类索引的分区处于不可用状态
SQL> alter system set skip_unusable_indexes=true;
System altered
SQL> select /*+ index(test_a)*/* from test_a where a=1;
select /*+ index(test_a)*/* from test_a where a=1
ORA-01502: 索引 'JUSTONE5.IDX_TEST_A' 或这类索引的分区处于不可用状态
-----------i am split----------------------------------------------
Connected to Oracle9i Enterprise Edition Release 9.2.0.8.0
Connected as justone4
SQL> show parameter skip
SQL> create table test_a(a number);
Table created
SQL> create index idx_test_a on test_a(a);
Index created
SQL> insert into test_a select rownum from dba_objects where rownum <1000;
999 rows inserted
SQL> commit;
Commit complete
SQL> alter index idx_test_a unusable;
Index altered
SQL> select * from test_a where a=1;
select * from test_a where a=1
ORA-01502: 索引'JUSTONE4.IDX_TEST_A'或这类索引的分区处于不可用状态
SQL> alter session set skip_unusable_indexes = true;
Session altered
SQL> select * from test_a where a=1;
select * from test_a where a=1
ORA-01502: 索引'JUSTONE4.IDX_TEST_A'或这类索引的分区处于不可用状态
SQL> alter system set skip_unusable_indexes = true;
alter system set skip_unusable_indexes = true
ORA-02065: 非法的 ALTER SYSTEM 选项
奇怪 9i中这个参数好像没有效果,待解决中。。。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7813229/viewspace-611470/ ,如需转载,请注明出处,否则将追究法律责任。