SQL> create unique index EMP_UK1 on emp(empno) tablespace users invisible;
Index created.
SQL> select index_name, visibility from user_indexes where table_name='EMP';
INDEX_NAME VISIBILIT
------------------------------ ---------
EMP_UK1 INVISIBLE
SQL> explain plan for
2 select /*+ index(EMP_UK1) */ * from emp where empno=3999;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 3956160932
--------------------------------------------------------------------------
Id Operation Name Rows Bytes Cost (%CPU) Time
--------------------------------------------------------------------------
0 SELECT STATEMENT 1 53 83 (0) 00:00:04
* 1 TABLE ACCESS FULL EMP 1 53 83 (0) 00:00:04
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
1 - filter("EMPNO"=3999)
13 rows selected.
SQL> alter session set optimizer_use_invisible_indexes=true;
Session altered.
SQL> explain plan for
2 select /*+ index(EMP_UK1) */ * from emp where empno=3999;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 2080524269
---------------------------------------------------------------------------------------
Id Operation Name Rows Bytes Cost (%CPU) Time
---------------------------------------------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
0 SELECT STATEMENT 1 53 2 (0) 00: 00:01
1 TABLE ACCESS BY INDEX ROWID EMP 1 53 2 (0) 00:00:01
* 2 INDEX UNIQUE SCAN EMP_UK1 1 1 (0) 00:00:01
---------------------------------------------------------------------------------------
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMPNO"=3999)
14 rows selected.
No comments:
Post a Comment