如何知道某个索引需要变成反转键索引

解决方案 »

  1.   

    查询条件是 字段 like '%条件值' 的
      

  2.   

    键值差别很小,做DML操作时又很容易发生在相邻的记录上,这样会导致热块产生,为了避免此种情况常采用反键索引。供参考
      

  3.   


    这位兄弟说话要复制,别忽悠别人啊。。create table t_test as select * from dba_objects;create index t_idx on t_test(object_name ) reverse;begin
      
    dbms_stats.gather_table_stats('HH7YX','t_test');
    end;explain plan for
    SELECT * FROm t_test t where t.object_name like '%TEST';select * from table(dbms_xplan.display());1  Plan hash value: 2796558804
    2   
    3  ----------------------------------------------------------------------------
    4 | Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    5 ----------------------------------------------------------------------------
    6 |   0 | SELECT STATEMENT  |        |  3802 |   360K|   294   (1)| 00:00:04 |
    7 |*  1 |  TABLE ACCESS FULL| T_TEST |  3802 |   360K|   294   (1)| 00:00:04 走的是全表扫描
      

  4.   

    2.5.3.2.5 Reverse Key Indexes
    These indexes are designed to eliminate index hot spots on insert applications. These indexes are excellent for insert performance, but they are limited because the database cannot use them for index range scans.
      

  5.   

    A reverse key index is a type of B-tree index that physically reverses the bytes of each index key while keeping the column order. For example, if the index key is 20, and if the two bytes stored for this key in hexadecimal are C1,15 in a standard B-tree index, then a reverse key index stores the bytes as 15,C1.Reversing the key solves the problem of contention for leaf blocks in the right side of a B-tree index. This problem can be especially acute in an Oracle Real Application Clusters (Oracle RAC) database in which multiple instances repeatedly modify the same block. For example, in an orders table the primary keys for orders are sequential. One instance in the cluster adds order 20, while another adds 21, with each instance writing its key to the same leaf block on the right-hand side of the index.In a reverse key index, the reversal of the byte order distributes inserts across all leaf keys in the index. For example, keys such as 20 and 21 that would have been adjacent in a standard key index are now stored far apart in separate blocks. Thus, I/O for insertions of sequential keys is more evenly distributed.Because the data in the index is not sorted by column key when it is stored, the reverse key arrangement eliminates the ability to run an index range scanning query in some cases. For example, if a user issues a query for order IDs greater than 20, then the database cannot start with the block containing this ID and proceed horizontally through the leaf blocks.