Oracle通过分区键值发现性能问题(二)

2014-11-24 17:14:11 · 作者: · 浏览: 1
120, 50 DATAH01 8 NO DISABLED YES 12-AUG-14
P120_C60 120, 60 DATAH01 8 NO DISABLED YES 12-AUG-14
P120_C70 120, 70 DATAH01 8 NO DISABLED YES 12-AUG-14
P120_C80 120, 80 DATAH01 8 NO DISABLED YES 12-AUG-14
P120_C90 120, 90 DATAH01 8 NO DISABLED YES 12-AUG-14
P120_C100 120, 100 DATAH01 8 NO DISABLED YES 12-AUG-14


根据最初的需求,是希望对于键值#1<120 键值#2<10的值,都能够插入到P120_C10 这个分区里面。
根据他们的期望,我对分区的数据进行了简单的分析,发现对于分区的键值在满足第一个分区的条件下,对于第二个键值的条件就直接忽略了。
select period_key,CUSTOMER_KEY from charge partition(P120_C10) group by period_key,CUSTOMER_KEY order by period_key,customer_key
SQL> /
42 0
42 1
42 2
....
42 14
42 15
42 16
42 17
...
42 99
43 0
...
44 99
45 0
45 1
45 2
45 3
45 4
...
45 98
45 99
46 0
46 1
46 2
46 3
46 4
46 5
46 6
46 7
46 8
46 9
46 10
46 11
46 12
...
57 88
57 89
57 90
57 91
57 92
57 93
57 94
57 95
57 96
57 97
57 98
57 99


create table test (period_key number,customer_key number)


partition by range(period_key,customer_key)


(


partition p120_c10 values less than (120,10),


partition p120_c20 values less than (120,20),


partition p120_c30 values less than (120,30)


);



SQL> insert into test values(57,99);


1 row created.


SQL> insert into test values(57,150);


1 row created.


SQL> insert into test values(120,5);


1 row created.


SQL> insert into test values(119,50);


1 row created.


SQL> insert into test values(120,5);


1 row created.


SQL> insert into test values(120,15);


1 row created.


SQL> insert into test values(120,25);


1 row created.


SQL> insert into test values(120,30);


insert into test values(120,30)


*


ERROR at line 1:


ORA-14400: inserted partition key does not map to any partition


SQL> insert into test values(121,1);


insert into test values(121,1)


*


ERROR at line 1:


ORA-14400: inserted partition key does not map to any partition



SQL> select *from test partition(p120_c10);


PERIOD_KEY CUSTOMER_KEY


---------- ------------


57 99


57 150


120 5


119 50


120 5



SQL> select *from test partition(p120_c20);


PERIOD_KEY CUSTOMER_KEY


---------- ------------


120 15



SQL> select *from test partition(p120_c30);


PERIOD_KEY CUSTOMER_KEY


---------- ------------


120 25



对于这个问题,只能根据业务的角度进行重新规划来把数据进一步balance了。