• 组合索引


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

    要让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 |
    -----------------------------------------------------------------------------
  • 相关阅读:
    hdu 4612 Warm up 桥缩点
    树上的一个题目
    2013 ACM/ICPC Asia Regional Online —— Warmup2
    hdu 3308 LCIS 线段树
    最近计划
    hdu 2121 , hdu 4009 无定根最小树形图
    POJ 3164 Command Network 最小树形图模板
    过滤器和拦截器
    struts中的请求数据自动封装
    struts中获取域
  • 原文地址:https://www.cnblogs.com/kramer/p/3899723.html
Copyright © 2020-2023  润新知