Monday, November 16, 2009

split PMAX partition with records inside

--my evn 10.2.0.2
Few things to take note during re-distribute records to new partitions:
1. Archived log gnerated , as rowmovement occurs. Rowid changed is the evidance. Here is my observation.
--rowid before split

select rowid, BILL_REF_NO, BILL_REF_RESETS from arbor.bill_invoice_detail partition(P01560_1) where BILL_REF_NO=155000001;

ROWID BILL_REF_NO BILL_REF_RESETS
------------------ ----------- ---------------
AAHsyTADUAABdzkAAD 155000001 1
AAHsyTADUAABdzkAAC 155000001 1
AAHsyTADUAABdzkAAB 155000001 1
AAHsyTADUAABdzkAAA 155000001 1

--split partition
10:55:50 SQL> alter table bill_invoice_detail split partition pmax
10:55:50 2 at (156000000,2) into (partition p01560_1 tablespace cust_bill_inv_det, partition pmax tablespace cust_bill_inv_det);

Table altered.

Elapsed: 00:09:44.28
11:05:34 SQL>
11:05:34 SQL> alter table bill_invoice_detail split partition pmax
11:05:34 2 at (157000000,2) into (partition p01570_1 tablespace cust_bill_inv_det, partition pmax tablespace cust_bill_inv_det);

Table altered.

Elapsed: 00:00:20.77
11:05:55 SQL>
11:05:55 SQL>
11:05:55 SQL> alter table bill_invoice_detail split partition pmax
11:05:55 2 at (158000000,2) into (partition p01580_1 tablespace cust_bill_inv_det, partition pmax tablespace cust_bill_inv_det);

Table altered.

Elapsed: 00:00:00.10
11:05:55 SQL>
11:05:55 SQL> alter table bill_invoice_detail split partition pmax
11:05:55 2 at (159000000,2) into (partition p01590_1 tablespace cust_bill_inv_det, partition pmax tablespace cust_bill_inv_det);

Table altered.

--rowid after split

select rowid, BILL_REF_NO, BILL_REF_RESETS from arbor.bill_invoice_detail partition(P01560_1) where BILL_REF_NO=155000001;

ROWID BILL_REF_NO BILL_REF_RESETS
------------------ ----------- ---------------
AAJM0sADXAABdzkAAG 155000001 1
AAJM0sADXAABdzkAAH 155000001 1
AAJM0sADXAABdzkAAI 155000001 1
AAJM0sADXAABdzkAAJ 155000001 1

2. Local index with records became unusable. Need to manually rebuild it.


11:20:07 SQL> exec dbms_stats.gather_table_stats(ownname=>'ARBOR', tabname=>'BILL_INVOICE_DETAIL');
BEGIN dbms_stats.gather_table_stats(ownname=>'ARBOR', tabname=>'BILL_INVOICE_DETAIL'); END;

*
ERROR at line 1:
ORA-20000: index "ARBOR"."BILL_INVOICE_DETAIL_PK" or partition of such index is in unusable state
ORA-06512: at "SYS.DBMS_STATS", line 13159
ORA-06512: at "SYS.DBMS_STATS", line 13179
ORA-06512: at line 1

13:24:09 SQL> select PARTITION_NAME, status from dba_ind_partitions where index_name='BILL_INVOICE_DETAIL_PK';

PARTITION_NAME STATUS
------------------------------ --------
P01470_1 USABLE
P01480_1 USABLE
P01490_1 USABLE
P01500_1 USABLE
P01510_1 USABLE
P01520_1 USABLE
P01530_1 USABLE
P01540_1 USABLE
P01550_1 USABLE
P01560_1 UNUSABLE
P01570_1 UNUSABLE
P01580_1 USABLE
P01590_1 USABLE
PMAX USABLE

14 rows selected.

13:28:27 SQL> alter index arbor.BILL_INVOICE_DETAIL_PK rebuild partition P01560_1 ;

Index altered.

Elapsed: 00:04:27.71
13:33:26 SQL> alter index arbor.BILL_INVOICE_DETAIL_PK rebuild partition P01570_1 ;

Index altered.

Elapsed: 00:01:47.79
13:36:04 SQL> select PARTITION_NAME, status from dba_ind_partitions where index_name='BILL_INVOICE_DETAIL_PK';

PARTITION_NAME STATUS
------------------------------ --------
P01470_1 USABLE
P01480_1 USABLE
P01490_1 USABLE
P01500_1 USABLE
P01510_1 USABLE
P01520_1 USABLE
P01530_1 USABLE
P01540_1 USABLE
P01550_1 USABLE
P01560_1 USABLE
P01570_1 USABLE
P01580_1 USABLE
P01590_1 USABLE
PMAX USABLE

14 rows selected.