Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / Database concepts.pdf
Скачиваний:
29
Добавлен:
12.05.2015
Размер:
6.96 Mб
Скачать

Partitioning Methods

A row is mapped to a partition by checking whether the value of the partitioning column for a row falls within the set of values that describes the partition. For example, the rows are inserted as follows:

(10, 'Jones', 'Hawaii', 100, '05-JAN-2000') maps to partition sales_ west

(21, 'Smith', 'Florida', 150, '15-JAN-2000') maps to partition sales_ east

(32, 'Lee’, 'Colorado', 130, '21-JAN-2000') does not map to any partition in the table

Unlike range and hash partitioning, multicolumn partition keys are not supported for list partitioning. If a table is partitioned by list, the partitioning key can only consist of a single column of the table.

The DEFAULT partition enables you to avoid specifying all possible values for a list-partitioned table by using a default partition, so that all rows that do not map to any other partition do not generate an error.

Hash Partitioning

Hash partitioning enables easy partitioning of data that does not lend itself to range or list partitioning. It does this with a simple syntax and is easy to implement. It is a better choice than range partitioning when:

You do not know beforehand how much data maps into a given range

The sizes of range partitions would differ quite substantially or would be difficult to balance manually

Range partitioning would cause the data to be undesirably clustered

Performance features such as parallel DML, partition pruning, and partition-wise joins are important

The concepts of splitting, dropping or merging partitions do not apply to hash partitions. Instead, hash partitions can be added and coalesced.

Partitioned Tables and Indexes 11-9

Partitioning Methods

Hash Partitioning Example

CREATE TABLE sales_hash (salesman_id NUMBER(5), salesman_name VARCHAR2(30), sales_amount NUMBER(10), week_no NUMBER(2)) PARTITION BY HASH(salesman_id) PARTITIONS 4

STORE IN (data1, data2, data3, data4);

The preceding statement creates a table sales_hash, which is hash partitioned on salesman_id field. The tablespace names are data1, data2, data3, and data4.

Composite Partitioning

Composite partitioning partitions data using the range method, and within each partition, subpartitions it using the hash or list method. Composite range-hash partitioning provides the improved manageability of range partitioning and the data placement, striping, and parallelism advantages of hash partitioning. Composite range-list partitioning provides the manageability of range partitioning and the explicit control of list partitioning for the subpartitions.

Composite partitioning supports historical operations, such as adding new range partitions, but also provides higher degrees of parallelism for DML operations and finer granularity of data placement through subpartitioning.

11-10 Oracle9i Database Concepts

Partitioning Methods

Composite Partitioning Range-Hash Example

CREATE TABLE sales_composite (salesman_id NUMBER(5), salesman_name VARCHAR2(30), sales_amount NUMBER(10), sales_date DATE) PARTITION BY RANGE(sales_date)

SUBPARTITION BY HASH(salesman_id) SUBPARTITION TEMPLATE( SUBPARTITION sp1 TABLESPACE data1, SUBPARTITION sp2 TABLESPACE data2, SUBPARTITION sp3 TABLESPACE data3, SUBPARTITION sp4 TABLESPACE data4)

(PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','DD/MM/YYYY')) PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','DD/MM/YYYY')) PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('04/01/2000','DD/MM/YYYY')) PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','DD/MM/YYYY'))

PARTITION sales_may2000 VALUES LESS THAN(TO_DATE('06/01/2000','DD/MM/YYYY')));

This statement creates a table sales_composite that is range partitioned on the sales_date field and hash subpartitioned on salesman_id. When you use a template, Oracle names the subpartitions by concatenating the partition name, an underscore, and the subpartition name from the template. Oracle places this subpartition in the tablespace specified in the template. In the previous statement, sales_jan2000_sp1 is created and placed in tablespace data1 while sales_ jan2000_sp4 is created and placed in tablespace data4. In the same manner, sales_apr2000_sp1 is created and placed in tablespace data1 while sales_ apr2000_sp4 is created and placed in tablespace data4. Figure 11–4 offers a graphical view of the previous example.

Partitioned Tables and Indexes 11-11

Partitioning Methods

Figure 11–4 Composite Range-Hash Partitioning

HASH(salesman_id)

 

 

 

 

 

Range(sales_date)

 

 

 

 

 

 

 

 

 

 

 

 

. . .

 

 

 

 

 

 

Sub-1

 

 

Sub-1

 

 

Sub-1

 

Sub-1

 

 

Sub-1

 

 

 

 

 

 

 

 

. . .

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sub-2

 

 

Sub-2

 

 

Sub-2

 

Sub-2

 

 

Sub-2

 

 

 

 

 

 

 

 

. . .

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sub-3

 

 

Sub-3

 

 

Sub-3

 

Sub-3

 

 

Sub-3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sub-4

 

 

Sub-4

 

 

Sub-4

. . .

 

Sub-4

 

 

Sub-4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Composite Partitioning Range-List Example

CREATE TABLE bimonthly_regional_sales (deptno NUMBER,

item_no VARCHAR2(20), txn_date DATE, txn_amount NUMBER, state VARCHAR2(2))

PARTITION BY RANGE (txn_date)

SUBPARTITION BY LIST (state) SUBPARTITION TEMPLATE(

SUBPARTITION east VALUES('NY', 'VA', 'FL') TABLESPACE ts1, SUBPARTITION west VALUES('CA', 'OR', 'HI') TABLESPACE ts2, SUBPARTITION central VALUES('IL', 'TX', 'MO') TABLESPACE ts3)

(

PARTITION janfeb_2000 VALUES PARTITION marapr_2000 VALUES PARTITION mayjun_2000 VALUES );

LESS THAN (TO_DATE('1-MAR-2000','DD-MON-YYYY')), LESS THAN (TO_DATE('1-MAY-2000','DD-MON-YYYY')), LESS THAN (TO_DATE('1-JUL-2000','DD-MON-YYYY'))

This statement creates a table bimonthly_regional_sales that is range partitioned on the txn_date field and list subpartitioned on state. When you use a template, Oracle names the subpartitions by concatenating the partition name, an underscore, and the subpartition name from the template. Oracle places this subpartition in the tablespace specified in the template. In the previous statement,

11-12 Oracle9i Database Concepts

Соседние файлы в папке Oracle selected docs