<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Neil的備忘錄

    just do it
    posts - 66, comments - 8, trackbacks - 0, articles - 0

    Index Skip Scanning

    Posted on 2009-01-21 15:22 Neil's NoteBook 閱讀(226) 評論(0)  編輯  收藏 所屬分類: ORACLE
    In previous releases a composite index could only be used if the first column, the leading edge, of the index was referenced in the WHERE clause of a statement. In Oracle9i this restriction is removed because the optimizer can perform skip scans to retrieve rowids for values that do not use the prefix.

    How It Works

    Rather than restricting the search path using a predicate from the statement, Skip Scans are initiated by probing the index for distinct values of the prefix column. Each of these distinct values is then used as a starting point for a regular index search. The result is several separate searches of a single index that, when combined, eliminate the affect of the prefix column. Essentially, the index has been searched from the second level down.

    The optimizer uses statistics to decide if a skip scan would be more efficient than a full table scan.

    Advantages

    This approach is advantageous because:
    • It reduces the number of indexes needed to support a range of queries. This increases performance by reducing index maintenance and decreases wasted space associated with multiple indexes.
    • The prefix column should be the most discriminating and the most widely used in queries. These two conditions do not always go hand in hand which makes the decision difficult. In these situations skip scanning reduces the impact of makeing the "wrong" decision.

    Example

    First, create and populate a test table with a concatenated index.
    CREATE TABLE test_objects AS
    SELECT * FROM all_objects;

    CREATE INDEX test_objects_i ON test_objects (owner, object_name, subobject_name);

    EXEC DBMS_STATS.gather_table_stats(USER, 'TEST_OBJECTS', cascade => TRUE);
    Next, run a query that hits the leading edge of the index. Notice the range scan on the index.
    SQL> SET AUTOTRACE ON
    SQL> SELECT owner, object_name
    2 FROM test_objects
    3 WHERE owner = 'SYS'
    4 AND object_name = 'DBMS_OUTPUT';

    OWNER OBJECT_NAME
    ------------------------------ ------------------------------
    SYS DBMS_OUTPUT

    1 row selected.


    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3650344004

    -----------------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    -----------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 1 | 32 | 2 (0)| 00:00:01 |
    |* 1 | INDEX RANGE SCAN| TEST_OBJECTS_I | 1 | 32 | 2 (0)| 00:00:01 |
    -----------------------------------------------------------------------------------
    Next, run a query that does not hit the leading edge of the index. Notice the index skip scan on the index.
    SQL> SET AUTOTRACE ON
    SQL> SELECT owner, object_name
    2 FROM test_objects
    3 WHERE object_name = 'DBMS_OUTPUT';

    OWNER OBJECT_NAME
    ------------------------------ ------------------------------
    PUBLIC DBMS_OUTPUT
    SYS DBMS_OUTPUT

    2 rows selected.


    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1293870291

    -----------------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    -----------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 2 | 64 | 14 (0)| 00:00:01 |
    |* 1 | INDEX SKIP SCAN | TEST_OBJECTS_I | 2 | 64 | 14 (0)| 00:00:01 |
    -----------------------------------------------------------------------------------
    Finally, clean up the test table.
    DROP TABLE test_objects;
    For more information see:
    Hope this helps. Regards Tim...

    原文地址: http://oracle-base.com/articles/9i/IndexSkipScanning.php#HowItWorks
    主站蜘蛛池模板: 亚洲最新中文字幕| 亚洲AV无码精品色午夜在线观看| 亚洲综合伊人制服丝袜美腿| 最近中文字幕高清免费中文字幕mv| 国产亚洲精品a在线无码| 免费无码黄网站在线看| 国产亚洲A∨片在线观看| 国产午夜无码精品免费看| 亚洲AV无码国产在丝袜线观看| 久别的草原电视剧免费观看| 亚洲国产综合专区电影在线| 51视频精品全部免费最新| 亚洲不卡中文字幕| 精品少妇人妻AV免费久久洗澡| 婷婷亚洲综合一区二区| 亚洲毛片网址在线观看中文字幕| 国产在线精品观看免费观看| 亚洲AV日韩AV鸥美在线观看| 亚洲美女视频免费| 亚洲精品无码少妇30P| 亚洲国产精品国产自在在线| 中国人免费观看高清在线观看二区 | 好湿好大好紧好爽免费视频| 国产AV无码专区亚洲A∨毛片| 3d成人免费动漫在线观看| 亚洲熟伦熟女专区hd高清| 国产乱子伦片免费观看中字| 99久久99这里只有免费的精品| 久久国产亚洲高清观看| 成人毛片免费观看视频大全| 一级毛片人与动免费观看| 久久久国产精品亚洲一区| 国内自产少妇自拍区免费| 国产免费内射又粗又爽密桃视频 | 亚洲an日韩专区在线| 免费国产怡红院在线观看| 国产高清不卡免费视频| 亚洲AV性色在线观看| 亚洲精品成人无限看| 成人无遮挡毛片免费看| 99热在线日韩精品免费|