zoukankan      html  css  js  c++  java
  • 组合索引

    组合索引,顾名思义是多个列组成的索引。它通常会比单列的索引更有效率。

    要让oracle能够使用到一个组合索引,要求where条件中要包含该索引的先导列。比如:

    create index ind1 on test(col1,col2,col3,col4);

    对于这个组合索引,只要where条件里有col1,那么就可以使用。

    有时候,where条件不包含先导列,也仍然可以使用组合索引。这种情况叫做索引跳跃扫描 index skip scan。 不过这种情况只有是先导列唯一值比较少才有意义。因为这种模式是对先导列的所有唯一值都执行查询。

    SQL> create table test as select * from dba_objects;
    
    Table created.
    
    SQL> create index test_ont on test(owner,object_name,object_type);
    
    Index created.
    
    SQL> exec dbms_stats.gather_table_stats('SYS','TEST',cascade=>true);
    
    PL/SQL procedure successfully completed.
    
    SQL> select owner,object_name,object_type from test where object_name='TEST';
    
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3426820653
    
    -----------------------------------------------------------------------------
    | Id  | Operation        | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |          |     2 |    80 |    22   (0)| 00:00:01 |
    |*  1 |  INDEX SKIP SCAN | TEST_ONT |     2 |    80 |    22   (0)| 00:00:01 |
    -----------------------------------------------------------------------------
  • 相关阅读:
    JavaScript 选取 min 到 max 之间的 length 个数字并排序
    css BFC
    css 清除浮动
    css hasLayout——IE浏览器css bug的一大罪恶根源
    css hack
    HTML React
    JavaScript 封装一些常用的函数
    dsoframer.ocx在win7下没法用
    DSO Framer ActiveX 控件
    c#读写txt文件
  • 原文地址:https://www.cnblogs.com/kramer/p/3899723.html
Copyright © 2011-2022 走看看