Oracle 索引的可见与隐藏(visible/invisible)
scott@ORCL>create table ti as select * from dba_objects;
Table created.
scott@ORCL>select count(*) from ti;
COUNT(*)
----------
72799
|
scott@ORCL>create index ind_ti on ti(object_id);
Index created.
|
scott@ORCL>set autot trace exp
|
scott@ORCL>select * from ti where object_id=20;
Execution Plan
----------------------------------------------------------
Plan hash value: 1655810896
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 207 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TI | 1 | 207 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IND_TI | 1 | | 1 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=20)
Note
-----
- dynamic sampling used for this statement (level=2)
|
scott@ORCL>alter index ind_ti invisible;
|
scott@ORCL>select * from ti where object_id=20;
Execution Plan
----------------------------------------------------------
Plan hash value: 798420002
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 12 | 2484 | 291 (1)| 00:00:04 |
|* 1 | TABLE ACCESS FULL| TI | 12 | 2484 | 291 (1)| 00:00:04 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"=20)
Note
-----
- dynamic sampling used for this statement (level=2)
|
scott@ORCL>insert into ti select * from ti;
72799 rows created.
scott@ORCL>insert into ti select * from ti;
145598 rows created.
scott@ORCL>select count(*) from ti;
COUNT(*)
----------
291196
|
scott@ORCL>alter index ind_ti visible;
Index altered.
|
scott@ORCL>set autot trace exp
scott@ORCL>select * from ti where object_id=20;
Execution Plan
----------------------------------------------------------
Plan hash value: 1655810896
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4 | 828 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TI | 4 | 828 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IND_TI | 4 | | 1 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=20)
Note
-----
- dynamic sampling used for this statement (level=2)
|
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。