ITPub博客

首页 > 数据库 > Oracle > 虚拟索引

虚拟索引

原创 Oracle 作者:duduyey 时间:2014-09-18 08:26:08 0 删除 编辑

虚拟索引(virtual index)是指没有创建对应的物理实体的索引。虚拟索引不分配具体的索引段,只是告诉优化器假设有个索引,用来测试是否需要添加索引

需要首先设置
alter session set optimizer_mode=rule;
alter session set "_use_nosegment_indexes"=true; 


查看虚拟索引

SELECT index_owner, index_name 
FROM dba_ind_columns  
WHERE index_name NOT LIKE 'BIN$%' 
MINUS  
SELECT owner, index_name FROM dba_indexes;

删除虚拟索引

drop index user01.INDEX_NAME_TEST03;


虚拟索引实验

USER01@aaron> create index vindex_test01 on test01(object_id) nosegment;

Index created.

USER01@aaron> alter session set "_use_nosegment_indexes"=TRUE;

Session altered.

USER01@aaron> explain plan for select * from test01 where object_id=54;

Explained.

USER01@aaron> select * from table(dbms_xplan.display());

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 2865676745

---------------------------------------------------------------------------------------------
| Id  | Operation              | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT         |              |     32 |  3104 |       2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| TEST01         |     32 |  3104 |       2   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN         | VINDEX_TEST01 |     32 |         |       1   (0)| 00:00:01 |
---------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------

   2 - access("OBJECT_ID"=54)

14 rows selected.



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

上一篇: 几个linux命令
下一篇: Find命令练习
请登录后发表评论 登录
全部评论

注册时间:2014-07-09

  • 博文量
    31
  • 访问量
    174869