Execution plan image:
Partition operation.
In an Oracle8i hash partition, rows are distributed to the various partitions based on the value of specific columns. However, in the case of hash partitions the column is subjected to a hashing algorithm to determine which partition stores the rows. The hashing algorithm applies a mathematical function to the column value and assigns the row to its partition based on the return value of the function. This ensures that each partition has approximately the same number of rows. It also means that you cannot reasonably anticipate which rows will end up in specific partitions. Rows that have adjacent column values will not necessarily end up in the same partition. They are usually allocated to separate partitions.
The following statement creates a variant of the SALES table that is partitioned by the hash of SALE_DATE. Six partitions are created with default storage attributes, though it could have explicitly named and supplied storage parameters for each partition:
CREATE TABLE SALES_HASH_PART
(column definitions)
PARTITION BY HASH (sale_date) PARTITIONS 8
The key advantage of hash partitions is that they are usually well-balanced: each partition will hold approximately the same number of rows. This improves the performance of many parallel operations on the partition.
Note: For a hash partition to be well-balanced using the default hashing algorithm, the number of partitions must be a power of 2 (i.e. 2, 4, 8, 16, 32).
The disadvantage of hash partitions is that you often will not get partition elimination for range-based queries such as "what were the total sales for quarter 4". Furthermore, you cannot purge old data using a hash partition. For example, a range partition that would have allowed you to easily remove all sales data for a specific year will require all the overhead of locating and removing each individual when you use hash partitioning.
Note: Consider hash partitioning when the balance of rows between partitions is more important than the benefits of partition elimination or purging data by dropping a partition. Remember to make the number of partitions a power of 2.
The HASH UNIQUE operation indexes and retrieves distinct rows using hashing.
Execution Plan image:
The following INDEX options are available:
Option |
Description |
Where Clause Example |
SINGLE VALUE |
Access a single value in the index and return a bitmap for all the matching rows. |
Where State = 'MD' |
FULL SCAN |
A complete scan of the index to find any matching values. |
Where State not in ('HI', 'AL') |
RANGE SCAN |
Access a range of values in the index and return multiple bitmaps. These bitmaps are then merged into one bitmap. |
Where City like 'New*' |
The INDEX BUILD NON UNIQUE operation builds an index where the ROWIDs are associated with the table.
© ALL RIGHTS RESERVED. Términos de uso Privacidad Cookie Preference Center