首页 > 其他 > 详细

【翻译自mos文章】关于分区索引:Global, Local, Prefixed and Non-Prefixed

时间:2017-07-22 22:00:55      阅读:258      评论:0      收藏:0      [点我收藏+]

来源于:

Partitioned Indexes: Global, Local, Prefixed and Non-Prefixed (文档 ID 69374.1)

 

APPLIES TO:

Oracle Database - Enterprise Edition - Version 8.0.3.0 and later
Information in this document applies to any platform.

PURPOSE


 
To differentiate between types of partitioned indexes.

SCOPE

 Engineers and customers.

DETAILS

RELATED DOCUMENTS
-----------------
 
Oracle Server Concepts

The different types of partitioned indexes are among the least-understood 
features associated with Oracle partitioned tables. This note aims to set 
out the definitions of each index type.

A partitioned table may have either partitioned or non-partitioned indexes; a 
non-partitioned table may have partitioned indexes. In practice, though, most  
partitioned indexes will be on partitioned tables.

LOCAL INDEXES
-------------

A local index is equi-partitioned with the underlying table, so each index 
partition has entries for rows in a single table partition. The partition 
bounds will be the same as for the table itself.

A local index may be prefixed or non-prefixed. A prefixed index is partitioned 
on the leftmost column(s) in the index. Since a local index, by definition, is 
partitioned on the same key as the table, a local prefixed index will have the 
table partition key as its leftmost column. 

So if we use as an example the following partitioned table:

    CREATE TABLE dept
    (deptno NUMBER NOT NULL,
    dname VARCHAR2(10) NOT NULL,
    loc VARCHAR2(14))
    PARTITION BY RANGE (deptno)
    (PARTITION part1 VALUES LESS THAN (30),
    PARTITION part2 VALUES LESS THAN (MAXVALUE));

Then a local prefixed index would be created as follows:

    CREATE  INDEX deptloc1_idx ON dept(deptno) LOCAL;

though we could be much more specific about partition names and tablespaces if 
we chose.

Local non-prefixed indexes will not have the table‘s partitioning key as their 
leftmost column. For example:

    CREATE  INDEX deptloc2_idx ON dept(loc) LOCAL;

Each partition of a non-prefixed local index will of course potentially contain the full 
range of possible key values, as shown in the diagram below:

          |                           |
       -------                     -------
      |       |                   |        |
      A..     Z..                 A..      Z..    (for a VARCHAR2 column)

This may look inefficient, but remember that we can search all the index 
partitions in parallel.


GLOBAL INDEXES
--------------

A global index is partitioned, but along different lines from the table. It 
may be on the same key, but different ranges; or it could be on a different 
key altogether.

Global non-prefixed indexes are not supported. This means that the index 
partitioning key must always be the leftmost index column. Anything else will 
raise the error:

ORA-14038:  GLOBAL partitioned index must be prefixed

Most examples of global indexes, in documentation and training material, use 
the same partitioning key as for the table, with different ranges. But global 
indexes are most powerful if they are partitioned on a different column from 
the table. For example (recalling that the DEPT table itself is partitioned on 
DEPTNO):

CREATE INDEX dept_idx ON dept(dname)
GLOBAL PARTITION BY RANGE (dname)
(PARTITION p1 VALUES LESS THAN (‘N‘),
PARTITION p2 VALUES LESS THAN (MAXVALUE));

To illustrate the usefulness of global indexes, imagine that we have a large 
fact table partitioned on a DATE column. We frequently need to search the table 
on a VARCHAR2 column (VCOL) which is not part of the table‘s partition key. 
Assume that there are currently 12 partitions in the table.

We could use 2 possible methods:
    
    A local non-prefixed index on VCOL:

                |                                         |
             -------                                   -------
            |       |         (10 more                |        |
Values:     A..     Z..   partitions here)            A..      Z.. 

        Or a global prefixed index on VCOL:

                 |                                         |
              -------                                   -------
             |       |         (10 more                |        |
Values:      A..     D..   partitions here)            T..      Z.. 

A global prefixed index would usually be the best choice for a unique index on 
our example VCOL column. For nonunique indexes, the issue is whether we can use
parallel index searches (local non-prefixed) or whether we need a serial search,
even at the expense of the greater maintenance problems of global indexes.

【翻译自mos文章】关于分区索引:Global, Local, Prefixed and Non-Prefixed

原文:http://www.cnblogs.com/wzjhoutai/p/7222913.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!