Oracle 11g新特性invisible index(不可见的索引)
来源:互联网 发布:美工代码 编辑:程序博客网 时间:2024/05/22 06:53
如果一张表上有十几个索引,你有什么感受?显然会拖慢增、删、改的速度,不要指望开发人员能建好索引。我的处理方法是先监控很长的一段时间,看哪些索引没有用到,然后删除。但删除以后,如果发现某一天有用,那又要重新建,如果是大表,那就有些麻烦。现在11g提供一个新特性,不可见索引,可以建索引设置为不可见索引,CBO在评估执行计划的时候会忽略它,如果需要的时候,设置回来即可。
还有一种用途,你在调试一条SQL语句,要建一个索引测试,而你不想影响其他的会话,用不可见索引正是时候。
SQL> drop table test purge;
SQL> create table test as select * from dba_objects;SQL> create index ind_t_object_id on test(object_id);
SQL> exec dbms_stats.gather_table_stats(user,'test',cascade => true);
SQL> set autotrace traceonly
SQL> select * from test where object_id = 10;
执行计划
----------------------------------------------------------
Plan hash value: 255872589
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 100 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 100 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IND_T_OBJECT_ID | 1 | | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=10)
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
4 consistent gets
0 physical reads
0 redo size
1195 bytes sent via SQL*Net to client
337 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> alter index ind_t_object_id invisible;
SQL> select * from test where object_id = 10;
执行计划
----------------------------------------------------------
Plan hash value: 1357081020
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 100 | 209 (1)| 00:00:03 |
|* 1 | TABLE ACCESS FULL| TEST | 1 | 100 | 209 (1)| 00:00:03 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"=10)
统计信息
----------------------------------------------------------
196 recursive calls
0 db block gets
567 consistent gets
0 physical reads
0 redo size
1195 bytes sent via SQL*Net to client
337 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select /*+ index(test ind_t_object_id)*/ * from test where object_id = 10;
执行计划
----------------------------------------------------------
Plan hash value: 1357081020
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 100 | 209 (1)| 00:00:03 |
|* 1 | TABLE ACCESS FULL| TEST | 1 | 100 | 209 (1)| 00:00:03 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"=10)
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
544 consistent gets
0 physical reads
0 redo size
1195 bytes sent via SQL*Net to client
337 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
--让数据库看到不可见索引,可以通过改变一个参数
SQL> alter session set optimizer_use_invisible_indexes = true;
SQL> select * from test where object_id = 10;
执行计划
----------------------------------------------------------
Plan hash value: 255872589
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 100 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 100 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IND_T_OBJECT_ID | 1 | | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=10)
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
4 consistent gets
0 physical reads
0 redo size
1195 bytes sent via SQL*Net to client
337 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
0 0
- Oracle 11g新特性invisible index(不可见的索引)
- Oracle 11g 新特性 -- Invisible Indexes(不可见的索引) 说明
- Oracle 11g 新特性 -- Invisible Indexes(不可见的索引) 说明
- Invisible Index --Oracle 11g 新特性
- Oracle 11g新特性:索引不可见
- Oracle 11g 新特性——隐式索引(Invisible Index)
- 11g新特性:Invisible Index
- 11g新特性_索引的可见与不可见
- Oracle 11g之不可见的索引
- Oracle Study---Oracle 11g 不可见索引案例
- Oracle11g新特性-不可见索引
- Oracle 11g 新特性 -- 虚拟索引!
- ArcSDE10.2.1使用Oracle12c新特性——不可见字段(Invisible Field)
- Oracle11g新特性:在线操作功能增强-Oracle11g新增的不可见索引 (转载)
- Oracle11新特性——在线操作功能增强之新增的不可见索引
- oracle 不可见索引
- oracle 12c:新特性-不可见字段
- oracle 12c 新特性之不可见字段
- 新手玩Linux 之 u-boot和kernel的编译和下载
- 冒泡排序实现(java)
- hdu3715 2-sat+二分
- 牛顿法与拟牛顿法学习笔记(二)拟牛顿条件
- javascript 实现 table 增加行
- Oracle 11g新特性invisible index(不可见的索引)
- 米浪饭揽餐饮系统:新一代订餐和餐厅管理神器,高端大气,新选择!
- acm steps 1.3.1(今年暑假不AC)
- TOJ--3073:Country Road 最小生成树(Prim)
- Qt-类型转换
- 牛顿法与拟牛顿法学习笔记(三)DFP 算法
- pair
- Laravel4.0使用redis,报错Call to undefined method Redis::connection()
- 工厂三兄弟之工厂方法模式