?
Solved

Insert is taking long time

Posted on 2009-04-10
3
Medium Priority
?
1,311 Views
Last Modified: 2013-12-19
The insert procedure which is select all the row at this moment taking long time.

Select query is giving result in only minutes.

We are getting waits on
log file switch completion
log file switch (checkpoint incomplete)
Latch free

Size of redo log is 50MB.

Please have a look.


Query:
 
Insert Query:
INSERT /*+parallel(TB_DIM_ALL_CUST_ACCT,3)*/
INTO TB_DIM_ALL_CUST_ACCT
  (ALL_CUST_SKEY,
   CUST_SKEY,
   MDM_PARTY_ID,
   MDM_SRCE_ID,
   CUST_SSK,
   DDD_NUM,
   DDD_SUB_CAT_CD,
   HIN,
   DEA_NUM,
   SRCE_CUST_TYPE_CD,
   SRCE_MDM_CUST_TYPE_CD,
   SRCE_ORG_NAME,
   SRCE_FULL_NAME,
   STAT_CD,
   CUST_EXCPTN_FLG,
   EFF_END_DATE,
   MDM_INS_DATE,
   MDM_LAST_MOD_DATE,
   DW_INS_DATE,
   DW_LAST_MOD_DATE,
   DW_LAST_MOD_BY,
   DW_SRCE_ID,
   CURR_IND)
--  explain plan for
  SELECT B.ALL_CUST_SKEY,
         B.CUST_SKEY,
         B.MDM_PARTY_ID,
         B.MDM_SRCE_ID,
         B.CUST_SSK,
         B.DDD_NUM,
         B.DDD_SUB_CAT_CD,
         B.HIN,
         B.DEA_NUM,
         B.SRCE_CUST_TYPE_CD,
         B.SRCE_MDM_CUST_TYPE_CD,
         B.SRCE_ORG_NAME,
         B.SRCE_FULL_NAME,
         B.STAT_CD,
         B.CUST_EXCPTN_FLG,
         B.EFF_END_DATE,
         B.MDM_INS_DATE,
         B.MDM_LAST_MOD_DATE,
         SYSDATE,
         SYSDATE,
         B.DW_LAST_MOD_BY,
         B.DW_SRCE_ID,
         B.CURR_IND
    FROM TB_DIM_ALL_CUST_ACCT_HIST B
   WHERE (B.CDW_EFF_START_DATE = TO_DATE('2009-03-25', 'YYYY-MM-DD') + 1 OR
         B.CUST_EXCPTN_FLG = 'Y')
     AND B.CURR_IND = 'C'
            AND NOT EXISTS (SELECT 1
            FROM TB_DIM_ALL_CUST_ACCT A
           WHERE A.ALL_CUST_SKEY = B.ALL_CUST_SKEY)
 
Explain Plan:
 
 
SQL Statement which produced this data:
  select * from table(dbms_xplan.display())
 
PLAN_TABLE_OUTPUT
Plan hash value: 713779952
 
-------------------------------------------------------------------------------------------------------------------
| Id  | Operation             | Name                      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
-------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |                           |  2513K|   431M|  8155   (2)| 00:02:27 |       |       |
|   1 |  NESTED LOOPS ANTI    |                           |  2513K|   431M|  8155   (2)| 00:02:27 |       |       |
|   2 |   PARTITION HASH ALL  |                           |  2513K|   400M|  8155   (2)| 00:02:27 |     1 |     3 |
|*  3 |    TABLE ACCESS FULL  | TB_DIM_ALL_CUST_ACCT_HIST |  2513K|   400M|  8155   (2)| 00:02:27 |     1 |     3 |
|*  4 |   INDEX FAST FULL SCAN| PK_TB_DIM_ALL_CUST_ACCT   |     1 |    13 |     0   (0)| 00:00:01 |       |       |
-------------------------------------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   3 - filter(("B"."CDW_EFF_START_DATE"=TO_DATE('2009-03-26 00:00:00', 'yyyy-mm-dd hh24:mi:ss') OR 
              "B"."CUST_EXCPTN_FLG"='Y') AND "B"."CURR_IND"='C')
   4 - filter("A"."ALL_CUST_SKEY"="B"."ALL_CUST_SKEY")

Open in new window

0
Comment
Question by:sachin_dba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:sachin_dba
ID: 24115052
On the dev DB where there is only one partition, and insert is running in 10 mins.

Explain plan and waits on session attached.
Dev:
 
--------------------------------------------------------------------------------------------------------------------
| Id  | Operation              | Name                      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
--------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |                           |     1 |   173 | 13889   (6)| 00:02:47 |       |       |
|   1 |  NESTED LOOPS ANTI     |                           |     1 |   173 | 13889   (6)| 00:02:47 |       |       |
|   2 |   PARTITION HASH SINGLE|                           |     1 |   167 | 13888   (6)| 00:02:47 |     1 |     1 |
|*  3 |    TABLE ACCESS FULL   | TB_DIM_ALL_CUST_ACCT_HIST |     1 |   167 | 13888   (6)| 00:02:47 |     1 |     1 |
|*  4 |   INDEX UNIQUE SCAN    | PK_TB_DIM_ALL_CUST_ACCT   |     1 |     6 |     1   (0)| 00:00:01 |       |       |
--------------------------------------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   3 - filter(("B"."CDW_EFF_START_DATE"=TO_DATE('2009-03-26 00:00:00', 'yyyy-mm-dd hh24:mi:ss') OR 
              "B"."CUST_EXCPTN_FLG"='Y') AND "B"."CURR_IND"='C')
   4 - access("A"."ALL_CUST_SKEY"="B"."ALL_CUST_SKEY")
 
Test:
 
-------------------------------------------------------------------------------------------------------------------
| Id  | Operation             | Name                      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
-------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |                           |  2513K|   431M|  8155   (2)| 00:02:27 |       |       |
|   1 |  NESTED LOOPS ANTI    |                           |  2513K|   431M|  8155   (2)| 00:02:27 |       |       |
|   2 |   PARTITION HASH ALL  |                           |  2513K|   400M|  8155   (2)| 00:02:27 |     1 |     3 |
|*  3 |    TABLE ACCESS FULL  | TB_DIM_ALL_CUST_ACCT_HIST |  2513K|   400M|  8155   (2)| 00:02:27 |     1 |     3 |
|*  4 |   INDEX FAST FULL SCAN| PK_TB_DIM_ALL_CUST_ACCT   |     1 |    13 |     0   (0)| 00:00:01 |       |       |

Open in new window

sess-waits.JPG
0
 
LVL 3

Accepted Solution

by:
mganesh earned 1000 total points
ID: 24121552
At first look, it looks you need to increase the redolog file size. 50MB is the default and is seldom enough for DMLs of decent weightage.

There are two things you can do initially:

1. Check the number of indexes on TB_DIM_ALL_CUST_ACCT and see if they are same in both your environments. Unwanted indexes slow down inserts.

2. I would suggest you to increase your redolog size to 256 MB at the minimum and observe the waits
0
 

Author Closing Comment

by:sachin_dba
ID: 31568859
No one looked at the explain plan.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question