Demantra Adding Partitions to SALES_DATA? Check out this 'sample' plan

Sample Action Plan to create partitions on Demantra Sales_data table.  This has been used recently and was successful.  USE at your own RISK after careful study and adjustment to meet your needs.  This was produced to use in an 11gr2 RDBMS environment.   

I will be providing a table_reorg action plan, available 7.3.1.3 and later soon for partitioned and non-partitioned tables.  These can be used to replace MyOracleSupport (MOS) note 1085012.1.

Ping me with any questions/comments.   Regards!   Jeff

conn / as sysdba
Run utlrp.sql / dbms_recomp  Recompile all the objects.
set pages 1000
set lines 300
spool demantra_object_status.lst
spool object_type,count(1) from dba_objects where owner='DEMANTRA' group by object_type order by 2;
select object_name,object_type,owner,status from dba_objects where status='INVALID';
spool off

1) EXP SALES_DATA TABLE

expdp Demantra/<PASSWD> table_name=SALES_DATA DIRECTORY=exportdir DUMPFILE=exptrans%U.dmp PARALLEL=3

2)Adding size to existing Tablespace to create the Partitions for NEW SALES_DATA
==================================================================================
Add 50GB of datafile space to  TABLESPACE "TS_SALES_DATA"

-Eg: Alter tablespace TS_SALES_DATA add datafile '<Location>/file_name' size n;

3) Creating  partition table for SALES_DATA and loading data into new table
===========================================================================
CREATE TABLE DEMANTRA.SALES_DATA_PART
  ((    "ITEM_ID" NUMBER(10,0) NOT NULL ENABLE,
    "LOCATION_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SALES_DATE" DATE NOT NULL ENABLE,
    "ITEM_PRICE" NUMBER(20,10),
    "SYNCRO_SIG" NUMBER(1,0) DEFAULT -1,
    "LAST_UPDATE_DATE" DATE DEFAULT SYSTIMESTAMP,
.
.
.
    "TOTALDISTRIBUCION" NUMBER(20,10),
    "BUDGET_VALOR" NUMBER(20,10),
    "PRON_PLDEM" NUMBER(20,10),
    "PRECIO_FUTURO" NUMBER(20,10),
    CONSTRAINT "SALES_DATA_PK" PRIMARY KEY ("ITEM_ID", "LOCATION_ID","SALES_DATE")
              USING INDEX PCTFREE 30 INITRANS 10 MAXTRANS 255
              TABLESPACE "TS_SALES_DATA_X" ENABLE)
         SEGMENT CREATION IMMEDIATE
   PARTITION BY RANGE (SALES_DATE)
PARTITION SALES_DATA_042010 VALUES LESS THAN (TO_DATE('01-May-2010','DD-MON-YYYY'))
  TABLESPACE TS_SALES_DATA1
PARTITION SALES_DATA_052010 VALUES LESS THAN (TO_DATE('01-JUN-2010','DD-MON-YYYY'))
  TABLESPACE TS_SALES_DATA2
.
.
.
PARTITION SALES_DATA_112014 VALUES LESS THAN (TO_DATE('01-DEC-2014','DD-MON-YYYY'))
  TABLESPACE TS_SALES_DATA15
PARTITION SALES_DATA_122014 VALUES LESS THAN (TO_DATE('01-JAN-2015','DD-MON-YYYY'))
  TABLESPACE TS_SALES_DATA16
as select * from demantra.sales_data
   PCTFREE 30 PCTUSED 60 INITRANS 10 MAXTRANS 255 NOCOMPRESS LOGGING PARALLEL 8
   STORAGE (INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
   FREELISTS 5 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
   );
 
 
3) Drop  SALES_DATA cascade / Please check the Export first step is completed and moved the dump to safe place.
=============================================================================================================================
Drop table DEMANTRA.SALES_DATA cascade;

5) rename new  Table name to SALES_DATA
===================================
      alter table SALES_DATA_PART
       rename to
       SALES_DATA;

5.1) GRANT ALTER, DELETE, INDEX, INSERT, REFERENCES, SELECT, UPDATE ON  SALES_DATA TO DEMANTRA;

Run utlrp.sql / dbms_recomp
spool Invalid_objects_after_Partition.lst
select object_name,object_type,owner,status from dba_objects where status='INVALID'
spool off
   
       
6) create dependencies for SALES_DATA After Renaming table back to Sales_DATA
==============================================================================
IMP: Try to Recompile all the objects so see all the dependent objects are valid (If not use the below scripts to create or replace the objects)

- Recreate the indexes on Sales_Data Table (Local)
i) Script to create the indexes on Sales_data table is sales_data_index_ddl.txt

spool index_sales_data.lst
select index_name,table_name,status from dba_indexes where table_name='SALES_DATA';
Spool off

- Create the Synonym
i) Script to create the synonym sales_synonym_ddl.txt

- Create Triggers on Sales_Data
i) Script to create triggers is sales_trigger_ddl.txt

IMP: This step have to do only if Step 5:- Recompile output shows Any demantra packages are invalid
- Try to recompile the Procedures/Packages of SALES_DATA If this does not work then recreate the procedures and packages
i) Script to use to recreate package is Package_body_Sales_Data.zip
ii) Scripts to use to recreate the Package body is Package_body_Sales_Data.zip

- Create Materialized View on Sales_data
i) BIEO_EXPORT_1_JUNTA_DEMAND.MV
ii) BIEO_EXPORT_2_JUNTA_DEMAND.MV

7)execute DBMS_STATS.DELETE_TABLE_STATS(ownname => 'DEMANTRA', tabname => 'SALES_DATA');

7.1)  collect stats on SALES_DATA

use this:

BEGIN    DBMS_STATS.GATHER_TABLE_STATS (      ownname          =>  '"DEMANTRA"',  ESTIMATE=>30 ,    tabname          =>  '"SALES_DATA"',      granularity      =>  'GLOBAL AND PARTITION',      cascade          =>  TRUE,      no_invalidate    =>  FALSE    ); END; /

Proof: 30% gathered.
Select table_name, last_analyzed,sample_size from user_tables;


spool index_sales_data.lst
select index_name,table_name,status from dba_indexes where table_name='SALES_DATA';
Spool off

i) Run utlrp.sql / dbms_recomp

ii) Please collect this data information:-
==============================================================
spool Demn_obj_status_after.lst
spool object_type,count(1) from dba_objects where owner='DEMANTRA' group by object_type order by 2;
select object_name,object_type,owner,status from dba_objects where status='INVALID';
spool off

8) Test eveything from application side

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

This blog delivers the latest information regarding performance and install/upgrade. Comments welcome

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today