您好,欢迎访问一九零五行业门户网

Oracle 11g 新特性 -- Invisible Indexes(不可见的索引) 说明

oracle 从版本11g 开始,可以创建不可见的索引。优化程序会忽略不可见的索引,除非在会话或系统级别上将 optimizer_use_invisibl
一.invisible indexes 说明
oracle 从版本11g 开始,可以创建不可见的索引。优化程序会忽略不可见的索引,除非在会话或系统级别上将 optimizer_use_invisible_indexes  初始化参数显式设置为true。此参数的默认值是false。
使索引不可见是使索引不可用或删除索引的一种替代办法。使用不可见的索引,可完成以下操作:
(1)  在删除索引之前测试对索引的删除。
(2)  对应用程序的特定操作或模块使用临时索引结构,这样就不会影响整个应用程序。
注意:
与不可用的索引不同,不可见的索引在使用dml 语句期间仍会得到维护。
当索引不可见时,优化程序生成的计划不会使用该索引。如果未发现性能下降,则可以删除该索引。还可以创建最初不可见的索引,执行测试,,然后确定是否使该索引可见。
可以查询*_indexes 数据字典视图的visibility 列来确定该索引是visible 还是invisible。
sql> select visibility from dba_indexes where index_name='idx_id';
visibilit
---------
visible
--创建不可见索引:
create index index_name ontable_name(column_name) invisible;
--修改索引是否可见:
alter index index_name invisible;
alter index index_name visible;
二.示例
--创建表,索引,并收集统计信息:
sql> create table dave(id number);
table created.
sql> begin
 2    for i in 1 .. 10000 loop
 3      insert into dave values(i);
 4    end loop;
 5    commit;
 6  end;
 7  /
pl/sql procedure successfully completed.
sql> create index idx_id on dave(id)invisible;
index created.
sql> execdbms_stats.gather_table_stats(ownname =>'&owner',tabname=>'&tablename',estimate_percent => &est_per ,method_opt =>'forall columns size 1',degree=>°ree,cascade => true);
enter value for owner: sys
enter value for tablename: dave
enter value for est_per: 50
enter value for degree: 2
pl/sql procedure successfully completed.
sql>
其它类似信息

推荐信息