Home » RDBMS Server » Performance Tuning » Tuning Insert (10.1.0.5.0)
Tuning Insert [message #503091] Tue, 12 April 2011 22:39 Go to next message
sunny17
Messages: 2
Registered: April 2011
Location: Bangalore
Junior Member
Hi All,

My first posting in this forum.

We have insert in the procudure which took 150 mins to execute it has insert which is taking around 140+ mins.
Below is the code


PROCEDURE refresh
  IS
    l_errm  VARCHAR(2000);
 
    --The data is being inserted into a synonym (REINS)
    --that points to the underlying table
 
  INSERT /*+ APPEND */  INTO REINS
      ( rcc,
        da_ceded_code
      )
      SELECT  DISTINCT nvl(rtrim(pre_explosion_rcc), nvl(rtrim(rcc),' ')) rcc,  
              trim(da_ceded_code) da_ceded_code        
        FROM  cl_trans_facts
       WHERE  acc_period > 197000
         AND  trim(da_ceded_code) between 1 and 8  
      UNION
      SELECT  DISTINCT nvl(rtrim(pre_explosion_rcc), nvl(rtrim(rcc),' ')) rcc,  
              trim(da_ceded_code) da_ceded_code         
        FROM  prem_trans_facts
       WHERE  acc_period > 197000
         AND  trim(da_ceded_code) between 1 and 8 
      UNION
      SELECT  DISTINCT nvl(rtrim(pre_explosion_rcc), nvl(rtrim(rcc),' ')) rcc,  
              trim(da_ceded_code) da_ceded_code         
        FROM  earn_prem_facts
       WHERE  acc_period > 197000
         AND  trim(da_ceded_code) between 1 and 8;
        
    COMMIT;
 
    INSERT  INTO status
    VALUES  ( SYSDATE, 'Success insert' );
    COMMIT;
 
      EXCEPTION
    WHEN OTHERS
      THEN  l_errm := SUBSTR( SQLERRM, 1, 2000 );
            INSERT  INTO ard_run_status
            VALUES  ( SYSDATE, l_errm );
            COMMIT;
 
  END refresh;


The tables (cl_trans_facts, prem_trans_facts, earn_prem_facts) are huge tables are around 750 gb and they belong to different schema. They are partitioned on acc_period and have partitioned index on all columns of those tables.

Please find the explain plan for the select statment.


explain plan for 
INSERT      /*+ APPEND */INTO reinsurance_bitmasks_load
            (rcc, direct_assumed_ceded_code)
   SELECT DISTINCT NVL (RTRIM (pre_explosion_rcc),
                        NVL (RTRIM (rcc), ' ')) rcc,
                   TRIM (direct_assumed_ceded_code) direct_assumed_ceded_code
              FROM claim_transaction_facts
             WHERE accounting_period > 197000
               AND TRIM (direct_assumed_ceded_code) BETWEEN 1 AND 8
   UNION
   SELECT DISTINCT NVL (RTRIM (pre_explosion_rcc),
                        NVL (RTRIM (rcc), ' ')) rcc,
                   TRIM (direct_assumed_ceded_code) direct_assumed_ceded_code
              FROM premium_transaction_facts
             WHERE accounting_period > 197000
               AND TRIM (direct_assumed_ceded_code) BETWEEN 1 AND 8
   UNION
   SELECT DISTINCT NVL (RTRIM (pre_explosion_rcc),
                        NVL (RTRIM (rcc), ' ')) rcc,
                   TRIM (direct_assumed_ceded_code) direct_assumed_ceded_code
              FROM earned_premium_facts
             WHERE accounting_period > 197000
               AND TRIM (direct_assumed_ceded_code) BETWEEN 1 AND 8
 
 
PLAN_TABLE_OUTPUT
 
Plan hash value: 1434373387
 
----------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                 | Name                      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib |
----------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | INSERT STATEMENT          |                           |  5832K|    77M|  9811K (92)| 21:44:08 |       |       |        |      |            |
|   1 |  LOAD AS SELECT           |                           |       |       |            |          |       |       |        |      |            |
|   2 |   PX COORDINATOR          |                           |       |       |            |          |       |       |        |      |            |
|   3 |    PX SEND QC (RANDOM)    | :TQ10001                  |  5832K|    77M|  9811K (92)| 21:44:08 |       |       |  Q1,01 | P->S | QC (RAND)  |
|   4 |     SORT UNIQUE           |                           |  5832K|    77M|  9811K (92)| 21:44:08 |       |       |  Q1,01 | PCWP |            |
|   5 |      PX RECEIVE           |                           |       |       |            |          |       |       |  Q1,01 | PCWP |            |
|   6 |       PX SEND HASH        | :TQ10000                  |       |       |            |          |       |       |  Q1,00 | P->P | HASH       |
|   7 |        UNION-ALL          |                           |       |       |            |          |       |       |  Q1,00 | PCWP |            |
|   8 |         PX BLOCK ITERATOR |                           |   735K|     9M|   869K  (2)| 01:55:33 |     1 |   385 |  Q1,00 | PCWC |            |
|*  9 |          TABLE ACCESS FULL| CLAIM_TRANSACTION_FACTS   |   735K|     9M|   869K  (2)| 01:55:33 |     1 |   385 |  Q1,00 | PCWP |            |
|  10 |         PX BLOCK ITERATOR |                           |  1493K|    19M|  2688K  (1)| 05:57:24 |     1 |   385 |  Q1,00 | PCWC |            |
|* 11 |          TABLE ACCESS FULL| PREMIUM_TRANSACTION_FACTS |  1493K|    19M|  2688K  (1)| 05:57:24 |     1 |   385 |  Q1,00 | PCWP |            |
|  12 |         PX BLOCK ITERATOR |                           |  4891K|    65M|  6252K  (2)| 13:51:08 |     1 |   385 |  Q1,00 | PCWC |            |
|* 13 |          TABLE ACCESS FULL| EARNED_PREMIUM_FACTS      |  4891K|    65M|  6252K  (2)| 13:51:08 |     1 |   385 |  Q1,00 | PCWP |            |
----------------------------------------------------------------------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   9 - filter(TO_NUMBER(TRIM("DIRECT_ASSUMED_CEDED_CODE"))>=1 AND TO_NUMBER(TRIM("DIRECT_ASSUMED_CEDED_CODE"))<=8 AND 
              "ACCOUNTING_PERIOD">197000)
  11 - filter(TO_NUMBER(TRIM("DIRECT_ASSUMED_CEDED_CODE"))>=1 AND TO_NUMBER(TRIM("DIRECT_ASSUMED_CEDED_CODE"))<=8 AND 
              "ACCOUNTING_PERIOD">197000)
  13 - filter(TO_NUMBER(TRIM("DIRECT_ASSUMED_CEDED_CODE"))>=1 AND TO_NUMBER(TRIM("DIRECT_ASSUMED_CEDED_CODE"))<=8 AND 
              "ACCOUNTING_PERIOD">197000)


Please suggest area as how we can tune the code.

Regards,
Sunny
Re: Tuning Insert [message #503092 is a reply to message #503091] Tue, 12 April 2011 22:47 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Please suggest area as how we can tune the code.

post DDL for all tables & indexes
Re: Tuning Insert [message #503096 is a reply to message #503092] Tue, 12 April 2011 23:24 Go to previous messageGo to next message
sunny17
Messages: 2
Registered: April 2011
Location: Bangalore
Junior Member
Sorry i didnt get what u mentioned.Can you please explain which DDL you refered?
Re: Tuning Insert [message #503099 is a reply to message #503096] Tue, 12 April 2011 23:32 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://en.wikipedia.org/wiki/Data_Definition_Language
Re: Tuning Insert [message #503128 is a reply to message #503099] Wed, 13 April 2011 02:35 Go to previous message
cookiemonster
Messages: 13958
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) Union does an implicit distinct so you don't need the distinct keyword.
2) How many rows in each table and how many rows do you expect each select to return?
3) How many partitions do expect the data to come from for each table? 1 or more?
4) Have you tried it with parallel switched off?
Previous Topic: Shall I kill these process...
Next Topic: subquery optimization (6 threads merged by bb)
Goto Forum:
  


Current Time: Sun Nov 24 20:39:40 CST 2024