Dears,
I have a problem regarding automatic list partitioning with hash sub-partitioning. the problem is the automatic created hash sub-partitions are not well distributed on the correct table spaces although the first hash-partitions are well distributed. the following example shows the problem :
I have created table as follow:
CREATE TABLE t3 (
id NUMBER,
description VARCHAR2(50),
year number,
created_date DATE,
CONSTRAINT t3_pk PRIMARY KEY (year,id))
;
then I altered it this way to make it partitioned:
alter table t3 modify
partition by list (year) automatic
subpartition by hash (id) subpartitions 3 store in (gls_ts_01,gls_ts_02,gls_ts_03)
(partition p1_2015 values (2015)) online;
and then run this query :
SELECT TABLE_NAME,PARTITION_NAME,SUBPARTITION_NAME,TABLESPACE_NAME FROM USER_TAB_SUBPARTITIONS WHERE TABLE_NAME='T3'
the result is fine as follow:
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME TABLESPACE_NAME
------------- ----------------- ------------------ ----------------------
T3 P1_2015 SYS_SUBP2748 GLS_TS_01
T3 P1_2015 SYS_SUBP2749 GLS_TS_02
T3 P1_2015 SYS_SUBP2750 GLS_TS_03
as you can see, each sub-partition is stored in different tablespace which is fine.
when adding anothr 'year' value an automatic partition is created with hash sub-partitions :
insert into t3 values (19, 'sadasd', 2016 , '01/jan/16');
Now when running the same request I got the following result:
select TABLE_NAME,PARTITION_NAME,subPARTITION_NAME,TABLESPACE_NAME from user_tab_subpartitions where TABLE_NAME='T3';
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME TABLESPACE_NAME
----------- --------------------- ------------------ ----------------------
T3 SYS_P2754 SYS_SUBP2752 GLS_TS
T3 SYS_P2754 SYS_SUBP2753 GLS_TS
T3 SYS_P2754 SYS_SUBP2751 GLS_TS
T3 P1_2015 SYS_SUBP2748 GLS_TS_01
T3 P1_2015 SYS_SUBP2749 GLS_TS_02
T3 P1_2015 SYS_SUBP2750 GLS_TS_03
as you notice all the new created hash sun-partitions are stored in the GLS-TS which is the list-partitions TS.
adding another different value for year will create 1 partition with 3 sub-partitions as follow:
insert into t3 values (42, 'sadasd', 2017 , '01/jan/17');
select TABLE_NAME,PARTITION_NAME,subPARTITION_NAME,TABLESPACE_NAME from user_tab_subpartitions where TABLE_NAME='T3';
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME TABLESPACE_NAME
---------------------- ---------------------- ---------------------- ----------------------
T3 SYS_P2754 SYS_SUBP2752 GLS_TS
T3 SYS_P2754 SYS_SUBP2753 GLS_TS
T3 SYS_P2754 SYS_SUBP2751 GLS_TS
T3 P1_2015 SYS_SUBP2748 GLS_TS_01
T3 P1_2015 SYS_SUBP2749 GLS_TS_02
T3 P1_2015 SYS_SUBP2750 GLS_TS_03
T3 SYS_P2758 SYS_SUBP2755 GLS_TS
T3 SYS_P2758 SYS_SUBP2756 GLS_TS
T3 SYS_P2758 SYS_SUBP2757 GLS_TS
9 rows selected.
as you notice all the new created hash sun-partitions are stored wrongly in the wrong TS.
Is there is a way to manage the new created sub-partitions to be distributed on the correct TSs ?
your early response will be greatly appreciated.
Thanks in advance for your help.
Regards,
Osama
You need to specify a subpartition template:
create tablespace ts1 datafile 'ts1.dbf' size 1m autoextend on;
create tablespace ts2 datafile 'ts2.dbf' size 1m autoextend on;
create tablespace ts3 datafile 'ts3.dbf' size 1m autoextend on;
CREATE TABLE t3 (
id NUMBER,
description VARCHAR2(50),
year number,
created_date DATE,
CONSTRAINT t3_pk PRIMARY KEY (year,id)
);
alter table t3 modify
partition by list (year) automatic
subpartition by hash (id) subpartition template (
subpartition p1 tablespace ts1,
subpartition p2 tablespace ts2,
subpartition p3 tablespace ts3
) (
partition p1_2015 values (2015)
) online;
select table_name,partition_name,subpartition_name,tablespace_name
from user_tab_subpartitions where table_name='T3';
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME TABLESPACE_NAME
T3 P1_2015 P1_2015_P1 TS1
T3 P1_2015 P1_2015_P2 TS2
T3 P1_2015 P1_2015_P3 TS3
insert into t3 values (19, 'sadasd', 2016 , date'2016-01-01');
insert into t3 values (42, 'sadasd', 2017 , date'2017-01-01');
select table_name,partition_name,subpartition_name,tablespace_name
from user_tab_subpartitions where table_name='T3';
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME TABLESPACE_NAME
T3 P1_2015 P1_2015_P1 TS1
T3 P1_2015 P1_2015_P2 TS2
T3 P1_2015 P1_2015_P3 TS3
T3 SYS_P731 SYS_SUBP729 TS2
T3 SYS_P731 SYS_SUBP730 TS3
T3 SYS_P731 SYS_SUBP728 TS1
T3 SYS_P735 SYS_SUBP732 TS1
T3 SYS_P735 SYS_SUBP733 TS2
T3 SYS_P735 SYS_SUBP734 TS3