日期:2014-05-16  浏览次数:20467 次

hash partition 平衡分布数据的测试

Thedestination of a row is determined by the internal hash function applied to therow by the database. The hashing algorithm is designed to evenly distributesrows across devices so that each partition contains about the same number ofrows.

官方文档说明hashpartition 能够平衡每个分区上面的行的个数,做了个小测试,记录下来,供大家参考。

1. 创建一个hash分区表 , 一共四个分区,分区名称由系统自动生成。
--也可以替换为 create table hash_t (id number ) partition by hash(id) (partition&part_name1,partition &part_name2,partition &part_name3,partition&part_name4) ;

dexter@ORCL>create tablehash_t (id number ) partition by hash(id) partitions 4 ;

Tablecreated.

--查看一下表的统计信息,可以看到blocks为空但是segment已经创建
dexter@ORCL> select TABLE_NAME, PARTITION_NAME, TABLESPACE_NAME ,NUM_ROWS  , BLOCKS , segment_created fromuser_tab_partitions ;

TABLE_NAMEPARTITION_NAME                TABLESPACE_NAME                 NUM_ROWS     BLOCKSSEG
---------- ------------------------------ ---------------------------------------- ---------- ---
HASH_T     SYS_P29                        USERS                                               YES
HASH_T     SYS_P28                        USERS                                               YES
HASH_T     SYS_P30                        USERS                                               YES
HASH_T     SYS_P31                        USERS                             &nbs