zoukankan      html  css  js  c++  java
  • Creating an Invisible Index

    OCP:053 

    22.An index called ORD_CUSTNAME_IX has been created on the CUSTNAME column in the ORDERS

    table using the following command:

    SQL>CREATE INDEX ord_custname_ix ON orders(custname);

    The ORDERS table is frequently queried using the CUSTNAME column in the WHERE clause. You want

    to check the impact on the performance of the queries if the index is not available. You do not want the

    index to be dropped or rebuilt to perform this test.

    Which is the most efficient method of performing this task?

    A. disabling the index

    B. making the index invisible

    C. making the index unusable

    D. using the MONITORING USAGE clause for the index

    Answer: B

    Creating an Invisible Index

    An invisible index is an index that is ignored by the optimizer unless you explicitly set the OPTIMIZER_USE_INVISIBLE_INDEXES initialization parameter to TRUE at the session or system level.

    To create an invisible index: 

    • Use the CREATE INDEX statement with the INVISIBLE keyword.

      The following statement creates an invisible index named emp_ename for the ename column of the emp table:

      CREATE INDEX emp_ename ON emp(ename)
            TABLESPACE users
            STORAGE (INITIAL 20K
            NEXT 20k) INVISIBLE;
     
    隐藏索引
    scott@TESTDB> create index emp_ename_i on emp(ename) invisible;
     
    Index created.
     
     
    scott@TESTDB> select index_name,VISIBILITY from user_indexes; 
     
    INDEX_NAME           VISIBILIT
    -------------------- ---------
    PK_EMP               VISIBLE
    EMP_SAL_F            VISIBLE
    EMP_COMM_I           VISIBLE
    EMP_ENAME_I          INVISIBLE
    PK_DEPT              VISIBLE
     
    scott@TESTDB> select * from emp where ename='KING';
     
     
    没有走索引
     
    切换到系统用户,修改参数
    sys@TESTDB> alter session set optimizer_use_invisible_indexes=true;
     
    Session altered.
    sys@TESTDB> select * from scott.emp where ename='KING';
     
     
     
    隐藏索引变正常索引或反之
    sys@TESTDB> alter index scott.emp_ename_i visible;
     
    Index altered.
     
    scott@TESTDB>  select index_name,VISIBILITY from user_indexes;
     
    INDEX_NAME                     VISIBILIT
    ------------------------------ ---------
    PK_EMP                         VISIBLE
    EMP_SAL_F                      VISIBLE
    EMP_COMM_I                     VISIBLE
    EMP_ENAME_I                    VISIBLE
    PK_DEPT                        VISIBLE
     
     
    多个索引,把慢的索引隐藏点,让他走快的索引
     
     
    scott@TESTDB> alter index emp_ename_i visible;
     
    Index altered.
     
    scott@TESTDB> alter index emp_ename_i invisible;
     
    Index altered.
  • 相关阅读:
    2016年终总结
    cocos2dx-3.x 导出自定义类到 lua 过程详解
    Direct3D11学习:(九)绘制基本几何体
    Direct3D11学习:(八)Effects介绍
    Direct3D11学习:(七)绘图基础——彩色立方体的绘制
    Direct3D11学习:(六)渲染管线
    Direct3D11学习:(五)演示程序框架
    Direct3D11学习:(四)计时和动画
    常见 Windows 函数列表
    驱动下通过进程PID获得进程名 (动态获取ImageFileName在EPROCESS结构体中的相对偏移)
  • 原文地址:https://www.cnblogs.com/gispf/p/3765931.html
Copyright © 2011-2022 走看看