|
Of all books or articles I read, Jonathan Lewis's "Practical Oracle8i" (pp.251-258) is still the best in describing the algorithm of how data are distributed in hash partitions, which partition's data is moved to a new partition when adding a partition, and which two partitions are "merged" when coalescing.
First, the number of values has to be large for data to be close to even distribution. So if you test, make sure you have at least a few thounsand, not 8条记录 for instance. And even thounsands of values does not mean they're absolutely evenly split.
Second, the book says you can use dbms_utility.get_hash_value to predict which partition to go to, for a string type column. Use base 0. And the result plus one is the partition number.
When you add a new hash partition, the partition whose data is partially moved to the new partition is the remainder (余数, as m in gszoracle's message #24) plus one. For instance, first you have 6 partitions. 6=4+2. When you add a new partition, it's partition 3 (i.e. 2+1) that contributes some rows to the new partition 7.
When you coalesce, it's the top partition and the remainder-numered partition. In the above case (without adding partition 7), it's 6 and 2 being merged.
Jonathan doesn't think dropping a hash partition would "make much sense". Unfortunately, he mentioned truncating a hash partition in the same paragraph without comments on why a truncate is allowed, by design. |
|