Nested Loop in Oracle 11g

Hi All,
I recently upgraded my Oracle DB from 10.2.0.4 to 11.2.0.3 on Aix 6.1
My below query is very slow after the upgrade
select count(*) from v$lock where block > 0;
I compared the explain plan and found that in 11g its using HASH JOIN while in 10g its using Nested Loop
When I am giving NL hint in 11g its returning fast.
I check almost all optimizer related DB parameters and its all are same as it in 10g.
Has anyone faced this issue in your DB upgrade or help me to find the reason
Thanks in advance

user12207083 wrote:
Thanks
But how come explan plan change for dynamic views
ThanksOrdered hint used in case of that query extracting from multiple tables, To define driving of that particular tables.
There are changes in explain plan. Am in learning stage in PT, You can expect response from Jonathan Lewis
Am just comparing those two explain plans.
SQL> set timing on
SQL> select count(*) from v$lock t1;
  COUNT(*)
       168
Elapsed: 00:00:00.01
SQL> select /*+ ordered */ count(*) from v$lock;
  COUNT(*)
       168
Elapsed: 00:00:00.02
SQL>
SQL> set autotrace traceonly explain;
SQL> set line 500
SQL> select count(*) from v$lock t1;
Elapsed: 00:00:00.00
Execution Plan                          "Without HINT"
Plan hash value: 2329815124
| Id  | Operation                 | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT          |                 |     1 |    50 |     1 (100)| 00:00:01 |
|   1 |  SORT AGGREGATE           |                 |     1 |    50 |            |          |
|   2 |   NESTED LOOPS            |                 |     1 |    50 |     1 (100)| 00:00:01 |
|*  3 |    HASH JOIN              |                 |     1 |    44 |     1 (100)| 00:00:01 |
|*  4 |     FIXED TABLE FULL      | X$KSUSE         |     1 |    19 |     0   (0)| 00:00:01 |
|   5 |     VIEW                  | GV$_LOCK        |    10 |   250 |     0   (0)| 00:00:01 |
|   6 |      UNION-ALL            |                 |       |       |            |          |
|*  7 |       FILTER              |                 |       |       |            |          |
|   8 |        VIEW               | GV$_LOCK1       |     2 |   178 |     0   (0)| 00:00:01 |
|   9 |         UNION-ALL         |                 |       |       |            |          |
|* 10 |          FIXED TABLE FULL | X$KDNSSF        |     1 |   102 |     0   (0)| 00:00:01 |
|* 11 |          FIXED TABLE FULL | X$KSQEQ         |     1 |   102 |     0   (0)| 00:00:01 |
|* 12 |       FIXED TABLE FULL    | X$KTADM         |     1 |   102 |     0   (0)| 00:00:01 |
|* 13 |       FIXED TABLE FULL    | X$KTATRFIL      |     1 |   102 |     0   (0)| 00:00:01 |
|* 14 |       FIXED TABLE FULL    | X$KTATRFSL      |     1 |   102 |     0   (0)| 00:00:01 |
|* 15 |       FIXED TABLE FULL    | X$KTATL         |     1 |   102 |     0   (0)| 00:00:01 |
|* 16 |       FIXED TABLE FULL    | X$KTSTUSC       |     1 |   102 |     0   (0)| 00:00:01 |
|* 17 |       FIXED TABLE FULL    | X$KTSTUSS       |     1 |   102 |     0   (0)| 00:00:01 |
|* 18 |       FIXED TABLE FULL    | X$KTSTUSG       |     1 |   102 |     0   (0)| 00:00:01 |
|* 19 |       FIXED TABLE FULL    | X$KTCXB         |     1 |   102 |     0   (0)| 00:00:01 |
|* 20 |    FIXED TABLE FIXED INDEX| X$KSQRS (ind:1) |     1 |     6 |     0   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   3 - access("SADDR"="S"."ADDR")
   4 - filter("S"."INST_ID"=USERENV('INSTANCE'))
   7 - filter(USERENV('INSTANCE') IS NOT NULL)
  10 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  11 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  12 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  13 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  14 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  15 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  16 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  17 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  18 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  19 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSPAFLG",1)<>0)
  20 - filter("RADDR"="R"."ADDR")
SQL>  select /*+ ordered */ count(*) from v$lock;                                "ORDERED HINT"
Elapsed: 00:00:00.01
Execution Plan                                                                 
Plan hash value: 3174212559
| Id  | Operation                 | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT          |                 |     1 |    50 |     1 (100)| 00:00:01 |
|   1 |  SORT AGGREGATE           |                 |     1 |    50 |            |          |
|   2 |   NESTED LOOPS            |                 |     1 |    50 |     1 (100)| 00:00:01 |
|*  3 |    HASH JOIN              |                 |     1 |    44 |     1 (100)| 00:00:01 |
|   4 |     VIEW                  | GV$_LOCK        |    10 |   250 |     0   (0)| 00:00:01 |
|   5 |      UNION-ALL            |                 |       |       |            |          |
|*  6 |       FILTER              |                 |       |       |            |          |
|   7 |        VIEW               | GV$_LOCK1       |     2 |   178 |     0   (0)| 00:00:01 |
|   8 |         UNION-ALL         |                 |       |       |            |          |
|*  9 |          FIXED TABLE FULL | X$KDNSSF        |     1 |   102 |     0   (0)| 00:00:01 |
|* 10 |          FIXED TABLE FULL | X$KSQEQ         |     1 |   102 |     0   (0)| 00:00:01 |
|* 11 |       FIXED TABLE FULL    | X$KTADM         |     1 |   102 |     0   (0)| 00:00:01 |
|* 12 |       FIXED TABLE FULL    | X$KTATRFIL      |     1 |   102 |     0   (0)| 00:00:01 |
|* 13 |       FIXED TABLE FULL    | X$KTATRFSL      |     1 |   102 |     0   (0)| 00:00:01 |
|* 14 |       FIXED TABLE FULL    | X$KTATL         |     1 |   102 |     0   (0)| 00:00:01 |
|* 15 |       FIXED TABLE FULL    | X$KTSTUSC       |     1 |   102 |     0   (0)| 00:00:01 |
|* 16 |       FIXED TABLE FULL    | X$KTSTUSS       |     1 |   102 |     0   (0)| 00:00:01 |
|* 17 |       FIXED TABLE FULL    | X$KTSTUSG       |     1 |   102 |     0   (0)| 00:00:01 |
|* 18 |       FIXED TABLE FULL    | X$KTCXB         |     1 |   102 |     0   (0)| 00:00:01 |
|* 19 |     FIXED TABLE FULL      | X$KSUSE         |     1 |    19 |     0   (0)| 00:00:01 |
|* 20 |    FIXED TABLE FIXED INDEX| X$KSQRS (ind:1) |     1 |     6 |     0   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   3 - access("SADDR"="S"."ADDR")
   6 - filter(USERENV('INSTANCE') IS NOT NULL)
   9 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  10 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  11 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  12 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  13 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  14 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  15 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  16 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  17 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSOBFLG",1)<>0)
  18 - filter(("KSQLKMOD"<>0 OR "KSQLKREQ"<>0) AND "INST_ID"=USERENV('INSTANCE') AND
              BITAND("KSSPAFLG",1)<>0)
  19 - filter("S"."INST_ID"=USERENV('INSTANCE'))
  20 - filter("RADDR"="R"."ADDR")
SQL>

Similar Messages

  • Oracle 11g - Nested loops on outer joins

    Hello,
    I have a select query that was working with no problems. The results are used to insert data into a temp table.
    Recently, it would not complete executing. The explain plan shows a cartesian. But, there could be problems with using nested loops on the outer join. Interestingly, when I copy production code and rename the temp table and rename the view, it works.
    Can someone take a look at the code and help. Maybe offer a suggestion on tuning too? Thanks.
    CREATE TABLE "CT"
    ( "TN" VARCHAR2(30) NOT NULL ENABLE,
    "COL_NAME" VARCHAR2(30) NOT NULL ENABLE,
    "CDE" VARCHAR2(5) NOT NULL ENABLE,
    "CDE_DESC" VARCHAR2(80) NOT NULL ENABLE,
    "CDE_STAT" CHAR(1));
    insert into CT (TN, COL_NAME, CDE, CDE_DESC, CDE_STAT)
    values ('INDSD', 'STCD', 'U', 'RF', 'A');
    insert into CT (TN, COL_NAME, CDE, CDE_DESC, CDE_STAT)
    values ('AT', 'TCD', '001', 'RL', 'A');
    insert into CT (TN, COL_NAME, CDE, CDE_DESC, CDE_STAT)
    values ('AT', 'TCD', '033', 'PFR', 'A');
    CREATE TABLE "IPP"
    ( "IND_ID" NUMBER(9,0) NOT NULL ENABLE,
    "PLCD" VARCHAR2(5) NOT NULL ENABLE,
    "CBCD" VARCHAR2(5));
    insert into IPP (IND_ID, PLCD, CBCD)
    values (2007, 'AS', '04');
    insert into IPP (IND_ID, PLCD, CBCD)
    values (797098, 'AS', '34');
    insert into IPP (IND_ID, PLCD, CBCD)
    values (797191, 'AS','04');
    CREATE TABLE "INDS"
    ( "OPCD" VARCHAR2(5) NOT NULL ENABLE,
    "IND_ID" NUMBER(9,0) NOT NULL ENABLE,
    "IND_CID" NUMBER(*,0),
    "GFLG" VARCHAR2(1),
    "HHID" NUMBER(9,0),
    "DOB" DATE,
    "DOB_FLAG" VARCHAR2(1),
    "VCD" VARCHAR2(5),
    "VTDTE" DATE,
    "VPPCD" VARCHAR2(4),
    "VRCDTE" DATE NOT NULL ENABLE,
    "VDSID" NUMBER(9,0),
    "VTRANSID" NUMBER(12,0),
    "VOWNCD" VARCHAR2(5),
    "RCDTE" DATE,
    "LRDTE" DATE
    insert into INDS (OPCD, IND_ID, IND_CID, GFLG, HHID, DOB, DOB_FLAG, VCD, VTDTE, VPPCD, VRCDTE, VDSID, VTRANSID, VOWNCD, RCDTE, LRDTE)
    values ('USST', 2007, 114522319, '', 304087673, to_date('01-01-1980', 'dd-mm-yyyy'), 'F', '2', to_date('06-04-2011 09:21:37', 'dd-mm-yyyy hh24:mi:ss'), '', to_date('06-04-2011 09:21:37', 'dd-mm-yyyy hh24:mi:ss'), 1500016, null, 'USST', to_date('06-04-2011 09:21:37', 'dd-mm-yyyy hh24:mi:ss'), to_date('18-07-2012 21:52:53', 'dd-mm-yyyy hh24:mi:ss'));
    insert into INDS (OPCD, IND_ID, IND_CID, GFLG, HHID, DOB, DOB_FLAG, VCD, VTDTE, VPPCD, VRCDTE, VDSID, VTRANSID, VOWNCD, RCDTE, LRDTE)
    values ('USST', 304087678, 115242519, '', 304087678, to_date('01-01-1984', 'dd-mm-yyyy'), 'F', '2', to_date('06-04-2011 09:21:39', 'dd-mm-yyyy hh24:mi:ss'), '', to_date('06-04-2011 09:21:39', 'dd-mm-yyyy hh24:mi:ss'), 1500016, null, 'USST', to_date('06-04-2011 09:21:39', 'dd-mm-yyyy hh24:mi:ss'), to_date('18-07-2012 21:52:53', 'dd-mm-yyyy hh24:mi:ss'));
    CREATE TABLE "INDS_TYPE"
    ( "IND_ID" NUMBER(9,0) NOT NULL ENABLE,
    "STCD" VARCHAR2(5) NOT NULL ENABLE);
    insert into INDS_type (IND_ID, STCD)
    values (2007, 'U');
    insert into INDS_type (IND_ID, STCD)
    values (313250322, 'U');
    insert into INDS_type (IND_ID, STCD)
    values (480058122, 'U');
    CREATE TABLE "PLOP"
    ( "OPCD" VARCHAR2(5) NOT NULL ENABLE,
    "PLCD" VARCHAR2(5) NOT NULL ENABLE,
    "PPLF" VARCHAR2(1));
    insert into PLOP (OPCD, PLCD, PPLF)
    values ('USST', 'SP', 'Y');
    insert into PLOP (OPCD, PLCD, PPLF)
    values ('PMUSA', 'ST', '');
    insert into PLOP (OPCD, PLCD, PPLF)
    values ('USST', 'RC', '');
    CREATE TABLE "IND_T"
    ( "OPCD" VARCHAR2(5) NOT NULL ENABLE,
    "CID" NUMBER(9,0) NOT NULL ENABLE,
    "CBCD" VARCHAR2(5),
    "PF" VARCHAR2(1) NOT NULL ENABLE,
    "DOB" DATE,
    "VCD" VARCHAR2(5),
    "VOCD" VARCHAR2(5),
    "IND_CID" NUMBER,
    "RCDTE" DATE NOT NULL ENABLE
    insert into IND_T (OPCD, CID, CBCD,PF, DOB, VCD, VOCD, IND_CID, RCDTE)
    values ('JMC', 2007, '04', 'F',to_date('11-10-1933', 'dd-mm-yyyy'), '2', 'PMUSA', 363004880, to_date('30-09-2009 04:31:34', 'dd-mm-yyyy hh24:mi:ss'));
    insert into IND_T (OPCD, CID, CBCD,PF, DOB, VCD, VOCD, IND_CID, RCDTE)
    values ('JMC', 2008, '04', 'N',to_date('01-01-1980', 'dd-mm-yyyy'), '2', 'PMUSA', 712606335, to_date('05-04-2013 19:36:05', 'dd-mm-yyyy hh24:mi:ss'));
    CREATE TABLE "IC"
    ( "CID" NUMBER(9,0) NOT NULL ENABLE,
    "CF" CHAR(1));
    insert into IC (CID, CF)
    values (2007, 'N');
    insert into IC (CID, CF)
    values (100, 'N');
    insert into IC (CID, CF)
    values (200, 'N');
    CREATE OR REPLACE FORCE VIEW "INDSS_V" ("OPCD", "IND_ID", "IND_CID", "GFLG", "HHID", "DOB", "DOB_FLAG", "VCD", "VTDTE", "VPPCD", "VRCDTE", "VDSID", "VTRANSID", "VOWNCD", "RCDTE", "LRDTE") AS
    SELECT DISTINCT a.OPCD, a.IND_ID, a.IND_CID, a.GFLG, a.HHID,
    a.DOB, a.DOB_flag, a.VCD, a.VTDTE,
    a.VPPCD, a.VRCDTE, a.VDSID, a.VTRANSID,
    a.VOWNCD, a.RCDTE, a.LRDTE
    FROM INDS a, INDS_type b
    WHERE a.IND_ID = b.IND_ID
    AND b.STCD in (select CDE
    from CT --database link
    where TN = 'INDSD'
    and COL_NAME = 'STCD'
    and CDE_STAT = 'A') ;
    --insert /*+ parallel(IND_T,2) */ into IND_T
    select /*+ parallel(a,4) */
    a.OPCD as OPCD
    , a.IND_ID as CID
    , b.CBCD as CBCD
    , NULL as BFCD
    , 'N' as PF
    , a.DOB as DOB
    , a.VCD as VCD
    , a.VOWNCD as VOCD
    , a.IND_CID as IND_CID
    , a.RCDTE as RCDTE
    from INDSS_V a
    , (select /*+ parallel(IPP,4) */ * from IPP IPP , PLOP PLO
    where plo.PLCD = ipp.PLCD
    and PPLF='Y') b
    , IC c
    where a.IND_ID = b.IND_ID (+)
    and a.OPCD = b.OPCD (+)
    and a.IND_ID = c.CID
    and c.CF = 'N';

    Please consult
    HOW TO: Post a SQL statement tuning request - template posting
    Also format your code and post it using the [ code ] and [ /code ] tags. (Leave out the extra space after [ and before ])
    Sybrand Bakker
    Senior Oracle DBA
    Edited by: sybrand_b on 10-apr-2013 17:57

  • When does oracle use a complete nested loop join?

    Hi!
    Does Oracle Database use a complete nested loop join? I mean, imagine 2 tables without any indexes.. is there any case where for each row in the outer table Oracle does a complete scan in the inner table? I know that this is the original algorithm for the nested loop join, but some data bases prefer to make a temp table to autoindex the inner table and never makes the complete scan in the inner table..
    thanks!!

    user12040235 wrote:
    If the table do not have indexes.. some data bases prefer to scan one time the inner table, to index all values, and than, for every row in the outter loop table, it will do a index search.
    I just like to know oracle does the same thing, or it does the complete scan..If you have two tables without indexes, Oracle may consider scanning one table, extracting the smallest data set it can get away with, and then building a hash table of that data set (rather than creating an in-memory copy with index). At this point Oracle can then do a nested loop join into the in-memory hash table.
    However, this is called a hash join, and the order of tables will appear to be reversed, viz:
    nested loop
        table scan full ABC
        table scan full XYZ
    {code]
    becomeshash join
    table scan full XYZ
    table scan full ABC
    See: http://jonathanlewis.wordpress.com/2010/08/02/joins/ as a starting point if you want to read more on this topic.
    Regards
    Jonathan Lewis                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Oracle 11g Migration performance issue

    Hello,
    There a performance issue with Migration from Oracle 10g(10.2.0.5) to Oracle 11g(11.2.0.2).
    Its very simple statement hanging for more than a day and later found that query plan is very very bad. Example of the query is given below:
    INSERT INTO TABLE_XYZ
    SELECT F1,F2,F3
    FROM TABLE_AB, TABLE_BC
    WHERE F1=F4;
    While looking at cost in Explain plan :
    on 10g --> 62567
    0n 11g --> 9879652356776
    Strange thing is that
    Scenario 1: if I issue just query as shown below, will display rows immediately :
    SELECT F1,F2,F3
    FROM TABLE_AB, TABLE_BC
    WHERE F1=F4;
    Scenario 2: If I create a table as shown below, will work correctly.
    CREATE TABLE TABLE_XYZ AS
    SELECT F1,F2,F3
    FROM TABLE_AB, TABLE_BC
    WHERE F1=F4;
    What could be the issue here with INSERT INTO <TAB> SELECT <COL> FROM <TAB1>?

    Table:
    CREATE TABLE AVN_WRK_F_RENEWAL_TRANS_T
    "PKSRCSYSTEMID" NUMBER(4,0) NOT NULL ENABLE,
    "PKCOMPANYCODE" VARCHAR2(8 CHAR) NOT NULL ENABLE,
    "PKBRANCHCODE" VARCHAR2(8 CHAR) NOT NULL ENABLE,
    "PKLINEOFBUSINESS" NUMBER(4,0) NOT NULL ENABLE,
    "PKPRODUCINGOFFICELIST" VARCHAR2(2 CHAR) NOT NULL ENABLE,
    "PKPRODUCINGOFFICE" VARCHAR2(8 CHAR) NOT NULL ENABLE,
    "PKEXPIRYYR" NUMBER(4,0) NOT NULL ENABLE,
    "PKEXPIRYMTH" NUMBER(2,0) NOT NULL ENABLE,
    "CURRENTEXPIRYCOUNT" NUMBER,
    "CURRENTRENEWEDCOUNT" NUMBER,
    "PREVIOUSEXPIRYCOUNT" NUMBER,
    "PREVIOUSRENEWEDCOUNT" NUMBER
    SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
    INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT
    TABLESPACE "XYZ" ;
    Explain Plan(With Insert Statement and Query):_
    INSERT STATEMENT, GOAL = ALL_ROWS               Cost=9110025395866     Cardinality=78120     Bytes=11952360
    LOAD TABLE CONVENTIONAL     Object owner=ODS     Object name=AVN_WRK_F_RENEWAL_TRANS               
    NESTED LOOPS OUTER               Cost=9110025395866     Cardinality=78120     Bytes=11952360
    TABLE ACCESS FULL     Object owner=ODS     Object name=AVN_WRK_F_RENEWAL_TRANS_1ST     Cost=115     Cardinality=78120     Bytes=2499840
    VIEW PUSHED PREDICATE     Object owner=ODS          Cost=116615788     Cardinality=1     Bytes=121
    SORT GROUP BY               Cost=116615788     Cardinality=3594     Bytes=406122
    VIEW     Object owner=SYS     Object name=VW_DAG_1     Cost=116615787     Cardinality=20168     Bytes=2278984
    SORT GROUP BY               Cost=116615787     Cardinality=20168     Bytes=4073936
    NESTED LOOPS OUTER               Cost=116614896     Cardinality=20168     Bytes=4073936
    VIEW     Object owner=SYS          Cost=5722     Cardinality=20168     Bytes=2157976
    NESTED LOOPS               Cost=5722     Cardinality=20168     Bytes=2097472
    HASH JOIN               Cost=924     Cardinality=1199     Bytes=100716
    NESTED LOOPS                         
    NESTED LOOPS               Cost=181     Cardinality=1199     Bytes=80333
    TABLE ACCESS BY INDEX ROWID     Object owner=ODS     Object name=INWARDSPOLICYDETAILS     Cost=159     Cardinality=1199     Bytes=39567
    INDEX RANGE SCAN     Object owner=ODS     Object name=IX_INWPOLDTLS_SYSCOMPANYBRANCH     Cost=7     Cardinality=1199     
    INDEX UNIQUE SCAN     Object owner=ODS     Object name=PK_AVN_D_MASTERPOLICYDETAILS     Cost=0     Cardinality=1     
    TABLE ACCESS BY INDEX ROWID     Object owner=ODS     Object name=AVN_D_MASTERPOLICYDETAILS     Cost=1     Cardinality=1     Bytes=34
    TABLE ACCESS FULL     Object owner=ODS     Object name=INWARDSPOLICYLOBMAPPING     Cost=741     Cardinality=288498     Bytes=4904466
    VIEW PUSHED PREDICATE     Object owner=ODS          Cost=4     Cardinality=1     Bytes=20
    FILTER                         
    SORT AGGREGATE                    Cardinality=1     Bytes=21
    TABLE ACCESS BY GLOBAL INDEX ROWID     Object owner=ODS     Object name=AVN_F_TRANSACTIONS     Cost=4     Cardinality=1     Bytes=21
    INDEX RANGE SCAN     Object owner=ODS     Object name=PK_AVN_F_TRANSACTIONS     Cost=3     Cardinality=1     
    VIEW PUSHED PREDICATE     Object owner=ODS          Cost=5782     Cardinality=1     Bytes=95
    SORT GROUP BY               Cost=5782     Cardinality=2485     Bytes=216195
    VIEW     Object owner=SYS     Object name=VW_DAG_0     Cost=5781     Cardinality=2485     Bytes=216195
    SORT GROUP BY               Cost=5781     Cardinality=2485     Bytes=278320
    HASH JOIN               Cost=5780     Cardinality=2485     Bytes=278320
    VIEW     Object owner=SYS     Object name=VW_GBC_15     Cost=925     Cardinality=1199     Bytes=73139
    SORT GROUP BY               Cost=925     Cardinality=1199     Bytes=100716
    HASH JOIN               Cost=924     Cardinality=1199     Bytes=100716
    NESTED LOOPS                         
    NESTED LOOPS               Cost=181     Cardinality=1199     Bytes=80333
    TABLE ACCESS BY INDEX ROWID     Object owner=ODS     Object name=INWARDSPOLICYDETAILS     Cost=159     Cardinality=1199     Bytes=39567
    INDEX RANGE SCAN     Object owner=ODS     Object name=IX_INWPOLDTLS_SYSCOMPANYBRANCH     Cost=7     Cardinality=1199     
    INDEX UNIQUE SCAN     Object owner=ODS     Object name=PK_AVN_D_MASTERPOLICYDETAILS     Cost=0     Cardinality=1     
    TABLE ACCESS BY INDEX ROWID     Object owner=ODS     Object name=AVN_D_MASTERPOLICYDETAILS     Cost=1     Cardinality=1     Bytes=34
    TABLE ACCESS FULL     Object owner=ODS     Object name=INWARDSPOLICYLOBMAPPING     Cost=741     Cardinality=288498     Bytes=4904466
    VIEW     Object owner=SYS     Object name=VW_GBF_16     Cost=4854     Cardinality=75507     Bytes=3850857
    SORT GROUP BY               Cost=4854     Cardinality=75507     Bytes=2340717
    VIEW     Object owner=ODS          Cost=4207     Cardinality=75507     Bytes=2340717
    SORT GROUP BY               Cost=4207     Cardinality=75507     Bytes=1585647
    PARTITION HASH ALL               Cost=3713     Cardinality=75936     Bytes=1594656
    TABLE ACCESS FULL     Object owner=ODS     Object name=AVN_F_TRANSACTIONS     Cost=3713     Cardinality=75936     Bytes=1594656
    Explain Plan(Only Query):_
    SELECT STATEMENT, GOAL = ALL_ROWS               Cost=62783     Cardinality=89964     Bytes=17632944
    HASH JOIN OUTER               Cost=62783     Cardinality=89964     Bytes=17632944
    TABLE ACCESS FULL     Object owner=ODS     Object name=AVN_WRK_F_RENEWAL_TRANS_1ST     Cost=138     Cardinality=89964     Bytes=2878848
    VIEW     Object owner=ODS          Cost=60556     Cardinality=227882     Bytes=37372648
    HASH GROUP BY               Cost=60556     Cardinality=227882     Bytes=26434312
    VIEW     Object owner=SYS     Object name=VW_DAG_1     Cost=54600     Cardinality=227882     Bytes=26434312
    HASH GROUP BY               Cost=54600     Cardinality=227882     Bytes=36005356
    HASH JOIN OUTER               Cost=46664     Cardinality=227882     Bytes=36005356
    VIEW     Object owner=SYS          Cost=18270     Cardinality=227882     Bytes=16635386
    HASH JOIN               Cost=18270     Cardinality=227882     Bytes=32587126
    HASH JOIN               Cost=12147     Cardinality=34667     Bytes=2912028
    HASH JOIN               Cost=10076     Cardinality=34667     Bytes=2322689
    TABLE ACCESS FULL     Object owner=ODS     Object name=AVN_D_MASTERPOLICYDETAILS     Cost=137     Cardinality=34667     Bytes=1178678
    TABLE ACCESS FULL     Object owner=ODS     Object name=INWARDSPOLICYDETAILS     Cost=9934     Cardinality=820724     Bytes=27083892
    TABLE ACCESS FULL     Object owner=ODS     Object name=INWARDSPOLICYLOBMAPPING     Cost=741     Cardinality=866377     Bytes=14728409
    VIEW     Object owner=ODS          Cost=5195     Cardinality=227882     Bytes=13445038
    HASH GROUP BY               Cost=5195     Cardinality=227882     Bytes=4785522
    PARTITION HASH ALL               Cost=3717     Cardinality=227882     Bytes=4785522
    TABLE ACCESS FULL     Object owner=ODS     Object name=AVN_F_TRANSACTIONS     Cost=3717     Cardinality=227882     Bytes=4785522
    VIEW     Object owner=ODS          Cost=26427     Cardinality=227882     Bytes=19369970
    HASH GROUP BY               Cost=26427     Cardinality=227882     Bytes=18686324
    VIEW     Object owner=SYS     Object name=VW_DAG_0     Cost=26427     Cardinality=227882     Bytes=18686324
    HASH GROUP BY               Cost=26427     Cardinality=227882     Bytes=25294902
    HASH JOIN               Cost=20687     Cardinality=227882     Bytes=25294902
    VIEW     Object owner=SYS     Object name=VW_GBC_15     Cost=12826     Cardinality=34667     Bytes=2080020
    HASH GROUP BY               Cost=12826     Cardinality=34667     Bytes=2912028
    HASH JOIN               Cost=12147     Cardinality=34667     Bytes=2912028
    HASH JOIN               Cost=10076     Cardinality=34667     Bytes=2322689
    TABLE ACCESS FULL     Object owner=ODS     Object name=AVN_D_MASTERPOLICYDETAILS     Cost=137     Cardinality=34667     Bytes=1178678
    TABLE ACCESS FULL     Object owner=ODS     Object name=INWARDSPOLICYDETAILS     Cost=9934     Cardinality=820724     Bytes=27083892
    TABLE ACCESS FULL     Object owner=ODS     Object name=INWARDSPOLICYLOBMAPPING     Cost=741     Cardinality=866377     Bytes=14728409
    VIEW     Object owner=SYS     Object name=VW_GBF_16     Cost=7059     Cardinality=227882     Bytes=11621982
    HASH GROUP BY               Cost=7059     Cardinality=227882     Bytes=6836460
    VIEW     Object owner=ODS          Cost=5195     Cardinality=227882     Bytes=6836460
    HASH GROUP BY               Cost=5195     Cardinality=227882     Bytes=4785522
    PARTITION HASH ALL               Cost=3717     Cardinality=227882     Bytes=4785522
    TABLE ACCESS FULL     Object owner=ODS     Object name=AVN_F_TRANSACTIONS     Cost=3717     Cardinality=227882     Bytes=4785522

  • Oracle 11g performance issue ( BITMAP CONVERSION TO ROWIDS)

    I have two instance of oracle 11g.
    in both instance i fired same query.
    one instance returns the result in 1sec but other instance returns the result in 10 sec
    following is explain plan for bot instance
    instance 1
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 143 | 59 (2)| 00:00:01 |
    | 1 | HASH GROUP BY | | 1 | 143 | 59 (2)| 00:00:01 |
    | 2 | VIEW | VM_NWVW_2 | 1 | 143 | 59 (2)| 00:00:01 |
    | 3 | HASH UNIQUE | | 1 | 239 | 59 (2)| 00:00:01 |
    | 4 | NESTED LOOPS | | | | | |
    | 5 | NESTED LOOPS | | 1 | 239 | 58 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    | 6 | NESTED LOOPS | | 1 | 221 | 57 (0)| 00:00:01 |
    | 7 | NESTED LOOPS | | 1 | 210 | 55 (0)| 00:00:01 |
    | 8 | NESTED LOOPS | | 1 | 184 | 54 (0)| 00:00:01 |
    | 9 | NESTED LOOPS | | 1 | 158 | 53 (0)| 00:00:01 |
    | 10 | NESTED LOOPS | | 1 | 139 | 52 (0)| 00:00:01 |
    | 11 | NESTED LOOPS | | 1 | 105 | 50 (0)| 00:00:01 |
    |* 12 | INDEX RANGE SCAN | year_field | 1 | 29 | 2 (0)| 00:00:01 |
    | 13 | SORT AGGREGATE | | 1 | 8 | | |
    | 14 | INDEX FULL SCAN (MIN/MAX)| idx_bf_creation_date | 1 | 8 | 2 (0)| 00:00:01 |
    |* 15 | TABLE ACCESS BY INDEX ROWID| OHRT_bugs_fact | 1 | 76 | 48 (0)| 00:00:01 |
    |* 16 | INDEX RANGE SCAN | idx_bf_creation_date | 76 | | 1 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 17 | TABLE ACCESS BY INDEX ROWID | OHRT_all_time_dimension | 1 | 34 | 2 (0)| 00:00:01 |
    |* 18 | INDEX UNIQUE SCAN | unique_alltime_bug_instance_id | 1 | | 1 (0)| 00:00:01 |
    | 19 | TABLE ACCESS BY INDEX ROWID | OHRT_all_time_dimension | 1 | 19 | 1 (0)| 00:00:01 |
    |* 20 | INDEX UNIQUE SCAN | unique_alltime_bug_instance_id | 1 | | 1 (0)| 00:00:01 |
    |* 21 | INDEX RANGE SCAN | bugseverity_instance_id_ref_id | 1 | 26 | 1 (0)| 00:00:01 |
    |* 22 | INDEX UNIQUE SCAN | unique_alltime_bug_instance_id | 1 | 26 | 1 (0)| 00:00:01 |
    | 23 | INLIST ITERATOR | | | | | |
    |* 24 | TABLE ACCESS BY INDEX ROWID | OHMT_ANL_BUCKET | 1 | 11 | 2 (0)| 00:00:01 |
    |* 25 | INDEX UNIQUE SCAN | SYS_C0053213 | 5 | | 1 (0)| 00:00:01 |
    |* 26 | INDEX RANGE SCAN | FK_BUCKET_TYPE | 6 | | 0 (0)| 00:00:01 |
    |* 27 | TABLE ACCESS BY INDEX ROWID | OHMT_ANL_BUCKET | 1 | 18 | 1 (0)| 00:00:01 |
    instance 2
    Plan
    SELECT STATEMENT ALL_ROWS Cost: 22 Bytes: 142 Cardinality: 1
    32 HASH GROUP BY Cost: 22 Bytes: 142 Cardinality: 1
    31 VIEW VIEW SYS.VM_NWVW_2 Cost: 22 Bytes: 142 Cardinality: 1
    30 HASH UNIQUE Cost: 22 Bytes: 237 Cardinality: 1
    29 NESTED LOOPS
    27 NESTED LOOPS Cost: 21 Bytes: 237 Cardinality: 1
    25 NESTED LOOPS Cost: 20 Bytes: 219 Cardinality: 1
    21 NESTED LOOPS Cost: 18 Bytes: 208 Cardinality: 1
    19 NESTED LOOPS Cost: 17 Bytes: 183 Cardinality: 1
    17 NESTED LOOPS Cost: 16 Bytes: 157 Cardinality: 1
    14 NESTED LOOPS Cost: 15 Bytes: 138 Cardinality: 1
    11 NESTED LOOPS Cost: 13 Bytes: 104 Cardinality: 1
    3 INDEX RANGE SCAN INDEX REPORTSDB.year_field Cost: 2 Bytes: 29 Cardinality: 1
    2 SORT AGGREGATE Bytes: 8 Cardinality: 1
    1 INDEX FULL SCAN (MIN/MAX) INDEX REPORTSDB.idx_bf_creation_date Cost: 3 Bytes: 8 Cardinality: 1
    10 TABLE ACCESS BY INDEX ROWID TABLE REPORTSDB.OHRT_bugs_fact Cost: 13 Bytes: 75 Cardinality: 1
    9 BITMAP CONVERSION TO ROWIDS
    8 BITMAP AND
    5 BITMAP CONVERSION FROM ROWIDS
    4 INDEX RANGE SCAN INDEX REPORTSDB.idx_OHRT_bugs_fact_2product Cost: 2 Cardinality: 85
    7 BITMAP CONVERSION FROM ROWIDS
    6 INDEX RANGE SCAN INDEX REPORTSDB.idx_bf_creation_date Cost: 2 Cardinality: 85
    13 TABLE ACCESS BY INDEX ROWID TABLE REPORTSDB.OHRT_all_time_dimension Cost: 2 Bytes: 34 Cardinality: 1
    12 INDEX UNIQUE SCAN INDEX (UNIQUE) REPORTSDB.unique_alltime_bug_instance_id Cost: 1 Cardinality: 1
    16 TABLE ACCESS BY INDEX ROWID TABLE REPORTSDB.OHRT_all_time_dimension Cost: 1 Bytes: 19 Cardinality: 1
    15 INDEX UNIQUE SCAN INDEX (UNIQUE) REPORTSDB.unique_alltime_bug_instance_id Cost: 1 Cardinality: 1
    18 INDEX UNIQUE SCAN INDEX (UNIQUE) REPORTSDB.unique_alltime_bug_instance_id Cost: 1 Bytes: 26 Cardinality: 1
    20 INDEX RANGE SCAN INDEX REPORTSDB.bugseverity_instance_id_ref_id Cost: 1 Bytes: 25 Cardinality: 1
    24 INLIST ITERATOR
    23 TABLE ACCESS BY INDEX ROWID TABLE OPSHUB.OHMT_ANL_BUCKET Cost: 2 Bytes: 11 Cardinality: 1
    22 INDEX UNIQUE SCAN INDEX (UNIQUE) OPSHUB.SYS_C0040939 Cost: 1 Cardinality: 5
    26 INDEX RANGE SCAN INDEX OPSHUB.FK_BUCKET_TYPE Cost: 0 Cardinality: 6
    28 TABLE ACCESS BY INDEX ROWID TABLE OPSHUB.OHMT_ANL_BUCKET Cost: 1 Bytes: 18 Cardinality: 1
    in both explain plan only difference is
    9 BITMAP CONVERSION TO ROWIDS
    8 BITMAP AND
    5 BITMAP CONVERSION FROM ROWIDS
    but is bitmap degrading performance lot?
    or suggest me what other parameter i can see so 2nd instance gives me better performace.

    I see more differences.
    In plan 1:
    * 16      INDEX RANGE SCAN      idx_bf_creation_date      76           1 (0)     00:00:01
    in Plan 2:
    1 INDEX FULL SCAN (MIN/MAX) INDEX REPORTSDB.idx_bf_creation_date Cost: 3 Bytes: 8 Cardinality: 1
    So this is not about "bitmap" good/bad, it about the access strategy which changed due to differences in data statistics etc. To analyze more, I'd help a LOT if those plans would be formated in a good and same way, use around it to do so.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Query tuning - oracle 11g

    Hi all,
    Query executes for more 1.5 hours. fetches the data from a remote database. more than million records.
    any suggestions to tune the query?
    Explain Plan
    CREATE TABLE STATEMENT  ALL_ROWSCost: 3,777  Bytes: 1,161,660  Cardinality: 15,285                      
         5 LOAD AS SELECT hcl_delta_TMP_2                
              4 NESTED LOOPS  Cost: 3,768  Bytes: 1,161,660  Cardinality: 15,285            
                   2 SORT UNIQUE  Cost: 1  Bytes: 693  Cardinality: 99       
                        1 INDEX FULL SCAN INDEX (UNIQUE) DELTA_REASON_CODES_PK Cost: 1  Bytes: 693  Cardinality: 99 
                   3 REMOTE REMOTE SERIAL_FROM_REMOTE PSM_LIB_LOG_R RMDB Cost: 74  Bytes: 10,626  Cardinality: 154       
    Query:
    CREATE TABLE hcl_delta_tmp_2 AS
    SELECT
    'hcl' AS heritage,
    load_dt,
    process_dt,
    update_status_cd,
    loan_number,
    lib_date,
    lib_time,
    lib_code,
    lib_user_id,
    lib_log_key_date_time
    FROM psm_lib_log_r@RMDB a
    WHERE a.process_dt >= TO_DATE('01/01/2010','MM/DD/YYYY') AND
    a.update_status_cd NOT IN( 'P' ) AND
    a.lib_code IN
    SELECT TRIM(delta_code) AS delta_code
    FROM delta_reason_codes
    Delta code column is a primary key in table delta_reason_codes: DELTA_REASON_CODES_PKVersion : Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    thanks.

    I think I am getting conflicting information about how many rows are in the remote table.
    First we read that the remote table has more than 10 million records and then we read that applying this where clause WHERE a.process_dt >= TO_DATE('01/01/2010','MM/DD/YYYY')
      AND a.update_status_cd NOT IN ('P') Results in that will be too many records, more than 10 millions.What are the total number of rows in the remote table?
    How many rows match the date condition by itself?
    How many match the status code condition by itself?
    How many match the lib_code condition by itself?
    How many rows match all conditions (the number returned by the query)?
    Sorry, but I am just trying clear up any confusion here.

  • Improve XML readability in Oracle 11g for binary XMLType storage for huge files

    I have one requirement in which I have to process huge XML files. That means there might be around 1000 xml files and the whole size of these files would be around 2GB.
    What I need is to store all the data in these files to my Oracle DB. For this I have used sqlloader for bulk uploading of all my XML files to my DB and it is stored as binary XMLTYPE in my database.Now I need to query these files and store the data in relational tables.For this I have used XMLTable Xpath queries. Everything is fine when I try to query single xml file within my DB. But if it is trying to query all those files it is taking too much time which is not acceptable.
    Here's my one sample xml content:
    <ABCD>
      <EMPLOYEE id="11" date="25-Apr-1983">
        <NameDetails>
          <Name NameType="a">
            <NameValue>
              <FirstName>ABCD</FirstName>
              <Surname>PQR</Surname>
              <OriginalName>TEST1</OriginalName>
              <OriginalName>TEST2</OriginalName>
            </NameValue>
          </Name>
          <Name NameType="b">
            <NameValue>
              <FirstName>TEST3</FirstName>
              <Surname>TEST3</Surname>
            </NameValue>
            <NameValue>
              <FirstName>TEST5</FirstName>
              <MiddleName>TEST6</MiddleName>
              <Surname>TEST7</Surname>
              <OriginalName>JAB1</OriginalName>
            </NameValue>
            <NameValue>
              <FirstName>HER</FirstName>
              <MiddleName>HIS</MiddleName>
              <Surname>LOO</Surname>
            </NameValue>
          </Name>
          <Name NameType="c">
            <NameValue>
              <FirstName>CDS</FirstName>
              <MiddleName>DRE</MiddleName>
              <Surname>QWE</Surname>
            </NameValue>
            <NameValue>
              <FirstName>CCD</FirstName>
              <MiddleName>YTD</MiddleName>
              <Surname>QQA</Surname>
            </NameValue>
            <NameValue>
              <FirstName>DS</FirstName>
              <Surname>AzDFz</Surname>
            </NameValue>
          </Name>
        </NameDetails>
      </EMPLOYEE >
    </ABCD>
    Please note that this is just one small record inside one big xml.Each xml would contain similar records around 5000 in number.Similarly there are more than 400 files each ranging about 4MB size approx.
    My xmltable query :
    SELECT t.personid,n.nametypeid,t.titlehonorofic,t.firstname,
            t.middlename,
            t.surname,
            replace(replace(t.maidenname, '<MaidenName>'),'</MaidenName>', '#@#') maidenname,
            replace(replace(t.suffix, '<Suffix>'),'</Suffix>', '#@#') suffix,
            replace(replace(t.singleStringName, '<SingleStringName>'),'</SingleStringName>', '#@#') singleStringName,
            replace(replace(t.entityname, '<EntityName>'),'</EntityName>', '#@#') entityname,
            replace(replace(t.originalName, '<OriginalName>'),'</OriginalName>', '#@#') originalName
    FROM xmlperson p,master_nametypes n,
             XMLTABLE (
              --'ABCD/EMPLOYEE/NameDetails/Name/NameValue'
              'for $i in ABCD/EMPLOYEE/NameDetails/Name/NameValue        
               return <row>
                        {$i/../../../@id}
                         {$i/../@NameType}
                         {$i/TitleHonorific}{$i/Suffix}{$i/SingleStringName}
                        {$i/FirstName}{$i/MiddleName}{$i/OriginalName}
                        {$i/Surname}{$i/MaidenName}{$i/EntityName}
                    </row>'
            PASSING p.filecontent
            COLUMNS
                    personid     NUMBER         PATH '@id',
                    nametypeid   VARCHAR2(255)  PATH '@NameType',
                    titlehonorofic VARCHAR2(4000) PATH 'TitleHonorific',
                     firstname    VARCHAR2(4000) PATH 'FirstName',
                     middlename  VARCHAR2(4000) PATH 'MiddleName',
                    surname     VARCHAR2(4000) PATH 'Surname',
                     maidenname   XMLTYPE PATH 'MaidenName',
                     suffix XMLTYPE PATH 'Suffix',
                     singleStringName XMLTYPE PATH 'SingleStringName',
                     entityname XMLTYPE PATH 'EntityName',
                    originalName XMLTYPE        PATH 'OriginalName'
                    ) t where t.nametypeid = n.nametype and n.recordtype = 'Person'
    But this is taking too much time to query all those huge data. The resultset of this query would return about millions of rows. I tried to index the table using this query :
    CREATE INDEX myindex_xmlperson on xml_files(filecontent) indextype is xdb.xmlindex parameters ('paths(include(ABCD/EMPLOYEE//*))');
    My Database version :
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Index is created but still no improvement with the performance though. It is taking more than 20 minutes to query even a set of 10 similar xml files.Now you can imagine how much will it take to query all those 1000 xml files.
    Could someone please suggest me how to improve the performance of my database.Since I am new to this I am not sure whether I am doing it in proper way. If there is a better solution please suggest. Your help will be greatly appreciated.

    Hi Odie..
    I tried to run your code through all the xml files but it is taking too much time. It has not ended even after 3hours.
    When I tried to do a single insert select statement  for one single xml it is working.But stilli ts in the range of ~10sec.
    Please find my execution plan for one single xml file with your code.
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 2771779566"
    "| Id  | Operation                                     | Name                                     | Rows   | Bytes | Cost (%CPU)| Time     |"
    "|   0 | INSERT STATEMENT                   |                                              |   499G |   121T |   434M  (2) |999:59:59  |"
    "|   1 |  LOAD TABLE CONVENTIONAL    | WATCHLIST_NAMEDETAILS  |            |           |                 |                 |"
    "|   2 |   SORT AGGREGATE                   |                                             |     1      |     2    |                 |          |"
    "|   3 |    XPATH EVALUATION                 |                                             |             |          |                 |          |"
    "|   4 |   SORT AGGREGATE                   |                                             |     1      |     2    |                 |          |"
    "|   5 |    XPATH EVALUATION                 |                                             |             |          |                 |          |"
    "|   6 |   SORT AGGREGATE                   |                                             |     1       |     2   |                 |          |"
    "|   7 |    XPATH EVALUATION                 |                                             |              |         |                 |          |"
    "|   8 |   SORT AGGREGATE                   |                                             |     1        |     2  |                 |          |"
    "|   9 |    XPATH EVALUATION                 |                                             |              |         |                 |          |"
    "|  10 |   NESTED LOOPS                       |                                             |   499G    | 121T |   434M (2) | 999:59:59 |"
    "|  11 |    NESTED LOOPS                      |                                             |    61M     |  14G |  1222K (1) | 04:04:28 |"
    "|  12 |     NESTED LOOPS                     |                                             | 44924      |  10M |    61   (2) | 00:00:01 |"
    "|  13 |      MERGE JOIN CARTESIAN      |                                             |     5         | 1235 |     6   (0) | 00:00:01 |"
    "|* 14 |       TABLE ACCESS FULL          | XMLPERSON                        |     1          |  221 |     2   (0) | 00:00:01 |"
    "|  15 |       BUFFER SORT                     |                                             |     6          |  156 |     4   (0) | 00:00:01 |"
    "|* 16 |        TABLE ACCESS FULL         | MASTER_NAMETYPES        |     6          |  156 |     3   (0) | 00:00:01 |"
    "|  17 |      XPATH EVALUATION             |                                             |                |         |               |          |"
    "|* 18 |     XPATH EVALUATION              |                                             |               |          |               |          |"
    "|  19 |    XPATH EVALUATION               |                                              |               |         |              |          |"
    "Predicate Information (identified by operation id):"
    "  14 - filter(""P"".""FILENAME""='PFA2_95001_100000_F.xml')"
    "  16 - filter(""N"".""RECORDTYPE""='Person')"
    "  18 - filter(""N"".""NAMETYPE""=CAST(""P1"".""C_01$"" AS VARCHAR2(255) ))"
    "Note"
    "   - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)"
    Please note that this is for a single xml file. I have like more than 400 similar files in the same table.
    And for your's as well as Jason's Question:
    What are you trying to accomplish with
    replace(replace(t.originalName, '<OriginalName>'),'</OriginalName>', '#@#') originalName 
    originalName XMLTYPE PATH 'OriginalName'
    Like Jason, I also wonder what's the purpose of all those XMLType projections and strange replaces in the SELECT clause
    What I was trying to achieve was to create a table containing separate rows for all the multi item child nodes for this particular xml.
    But since there was an error beacuse of multiple child nodes like 'ORIGINALNAME' under 'NAMEVALUE' node, I tried this script to insert those values by providing a delimiter and replacing the tag names.
    Please see the link for more details - http://stackoverflow.com/questions/16835323/construct-xmltype-query-to-store-data-in-oracle11g
    This was the execution plan for one single xml file with my code :
    Plan hash value: 2851325155
    | Id  | Operation                                                     | Name                                         | Rows  | Bytes   | Cost (%CPU)  | Time       |    TQ  | IN-OUT | PQ Distrib |
    |   0 | SELECT STATEMENT                                   |                                                 |  7487   |  1820K |    37   (3)        | 00:00:01 |           |             |            |
    |*  1 |  HASH JOIN                                                 |                                                 |  7487   |  1820K  |    37   (3)        | 00:00:01 |           |             |            |
    |*  2 |   TABLE ACCESS FULL                                | MASTER_NAMETYPES            |     6     |   156     |     3   (0)         | 00:00:01 |           |             |            |
    |   3 |   NESTED LOOPS                                        |                                                 |  8168   |  1778K  |    33   (0)        | 00:00:01 |           |             |            |
    |   4 |    PX COORDINATOR                                    |                                                 |            |             |                      |               |           |             |            |
    |   5 |     PX SEND QC (RANDOM)                           | :TQ10000                                  |     1    |   221      |     2   (0)        | 00:00:01 |  Q1,00 | P->S     | QC (RAND)  |
    |   6 |      PX BLOCK ITERATOR                              |                                                 |     1    |   221      |     2   (0)        | 00:00:01 |  Q1,00 | PCWC   |            |
    |*  7 |       TABLE ACCESS FULL                            | XMLPERSON                            |     1    |   221      |     2   (0)        | 00:00:01 |  Q1,00 | PCWP   |            |
    |   8 |    COLLECTION ITERATOR PICKLER FETCH  | XQSEQUENCEFROMXMLTYPE |  8168  | 16336    |    29   (0)       | 00:00:01  |           |               |            |
    Predicate Information (identified by operation id):
       1 - access("N"."NAMETYPE"=CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/*/@NameType'),0,0,20971520,0),50,1,2
                  ) AS VARCHAR2(255)  ))
       2 - filter("N"."RECORDTYPE"='Person')
       7 - filter("P"."FILENAME"='PFA2_95001_100000_F.xml')
    Note
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)
    Please let me know whether this has helped.
    My intention is to save the details in the xml to different relational tables so that I can easily query it from my application. I have similarly many queries which inserts the xml values to different tables like the one which I have mentioned here. I was thinking of creating a stored procedure to insert all these values in the relational tables once I receive the xml files. But even a single query is taking too much time to complete. Could you please help me in this regard. Waiting for your valuable feedback.

  • Oracle 11g  Quartz Scheduler 1.8.5 running under JBOSS 5.1

    Basically I'm getting this error when running Quartz configured for the jobStore
    org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
    I've got two data sources setup.
    One data source is setup to be looked up via JNDI (presumably for the one that may participate in distributed JTA XA transactions) and one that
    supposedly is not to participate in JTA transactions in which quartz can call commit/rollback on it's own.
    The problem I'm seeing with the interaction of the two is the following exception:
    05:21:27,292 ERROR [TxPolicy] javax.ejb.EJBTransactionRolledbackException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [9
    9999]; error code [29875];
    --- The error occurred in XXXXX_COORDINATE_SqlMap.xml.
    --- The error occurred while applying a parameter map.
    --- Check the XXXX_COORDINATE.insert-InlineParameterMap.
    --- Check the statement (update failed).
    --- Cause: java.sql.SQLException: ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
    ORA-29400: data cartridge error
    ORA-14450: attempt to access a transactional temp table already in use
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 720
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 225
    ; nested exception is com.XXXXXibatis.common.jdbc.exception.NestedSQLException:
    --- The error occurred in XXXXX_COORDINATE_SqlMap.xml.
    --- The error occurred while applying a parameter map.
    --- Check the XXXXX_COORDINATE.insert-InlineParameterMap.
    --- Check the statement (update failed).
    --- Cause: java.sql.SQLException: ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
    ORA-29400: data cartridge error
    ORA-14450: attempt to access a transactional temp table already in use
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 720
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 225
    Has anyone seen this error before with the following configuration of Quartz 1.8.5, Oracle 11g, Oracle Spatial?
    I've googled and seen reference to Oracle spatial using temp tables and not compatible with transactions... but not sure
    exactly how to solve this problem.
    Thanks in advacce.

    Hi;
    Can any one advise me where and how can I download proper RPM packages and how do I resolve swap space requirement failure as mentioned above. Please let me know if further information required.You can find all related rpm from your DVD. For rpm please see below thread:
    RPM confirmation
    Re: Package install for oracle11gr2
    For swap:
    swap size increase-linux
    How to increase swap size?
    Regard
    Helios

  • The danger of memory target in Oracle 11g - request for discussion.

    Hello, everyone.
    This is not a question, but kind of request for discussion.
    I believe that many of you heard something about automatic memory management in Oracle 11g.
    The concept is that Oracle manages the target size of SGA and PGA. Yes, believe it or not, all we have to do is just to tell Oracle how much memory it can use.
    But I have a big concern on this. The optimizer takes the PGA size into consideration when calculating the cost of sort-related operations.
    So what would happen when Oracle dynamically changes the target size of PGA? Following is a simple demonstration of my concern.
    UKJA@ukja116> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    -- Configuration
    *.memory_target=350m
    *.memory_max_target=350m
    create table t1(c1 int, c2 char(100));
    create table t2(c1 int, c2 char(100));
    insert into t1 select level, level from dual connect by level <= 10000;
    insert into t2 select level, level from dual connect by level <= 10000;
    -- First 10053 trace
    alter session set events '10053 trace name context forever, level 1';
    select /*+ use_hash(t1 t2) */ count(*)
    from t1, t2
    where t1.c1 = t2.c1 and t1.c2 = t2.c2
    alter session set events '10053 trace name context off';
    -- Do aggressive hard parse to make Oracle dynamically change the size of memory segments.
    declare
      pat1     varchar2(1000);
      pat2     varchar2(1000);
      va       number;
      vc       sys_refcursor;
      vs        varchar2(1000);
    begin
      select ksppstvl into pat1
        from sys.xm$ksppi i, sys.xm$ksppcv v   -- views for x$ table
        where i.indx = v.indx
        and i.ksppinm = '__pga_aggregate_target';
      for idx in 1 .. 10000000 loop
        execute immediate 'select count(*) from t1 where rownum = ' || (idx+1)
              into va;
        if mod(idx, 1000) = 0 then
          sys.dbms_system.ksdwrt(2, idx || 'th execution');
          select ksppstvl into pat2
          from sys.xm$ksppi i, sys.xm$ksppcv v   -- views for x$ table
          where i.indx = v.indx
          and i.ksppinm = '__pga_aggregate_target';
          if pat1 <> pat2 then
            sys.dbms_system.ksdwrt(2, 'yep, I got it!');
            exit;
          end if;
        end if;
      end loop;
    end;
    -- As to alert log file,
    25000th execution
    26000th execution
    27000th execution
    28000th execution
    29000th execution
    30000th execution
    yep, I got it! <-- the pga target changed with 30000th hard parse
    -- Second 10053 trace for same query
    alter session set events '10053 trace name context forever, level 1';
    select /*+ use_hash(t1 t2) */ count(*)
    from t1, t2
    where t1.c1 = t2.c1 and t1.c2 = t2.c2
    alter session set events '10053 trace name context off';With above test case, I found that
    1. Oracle invalidates the query when internal pga aggregate size changes, which is quite natural.
    2. With changed pga aggregate size, Oracle recalculates the cost. These are excerpts from the both of the 10053 trace files.
    -- First 10053 trace file
    PARAMETERS USED BY THE OPTIMIZER
      PARAMETERS WITH ALTERED VALUES
    Compilation Environment Dump
    _smm_max_size                       = 11468 KB
    _smm_px_max_size                    = 28672 KB
    optimizer_use_sql_plan_baselines    = false
    optimizer_use_invisible_indexes     = true
    -- Second 10053 trace file
    PARAMETERS USED BY THE OPTIMIZER
      PARAMETERS WITH ALTERED VALUES
    Compilation Environment Dump
    _smm_max_size                       = 13107 KB
    _smm_px_max_size                    = 32768 KB
    optimizer_use_sql_plan_baselines    = false
    optimizer_use_invisible_indexes     = true
    Bug Fix Control Environment10053 trace file clearly says that Oracle recalculates the cost of the query with the change of internal pga aggregate target size. So, there is a great danger of unexpected plan change while Oracle dynamically controls the memory segments.
    I believe that this is a desinged behavior, but the negative side effect is not negligible.
    I just like to hear your opinions on this behavior.
    Do you think that this is acceptable? Or is this another great feature that nobody wants to use like automatic tuning advisor?
    ================================
    Dion Cho - Oracle Performance Storyteller
    http://dioncho.wordpress.com (english)
    http://ukja.tistory.com (korean)
    ================================

    I made a slight modification with my test case to have mixed workloads of hard parse and logical reads.
    *.memory_target=200m
    *.memory_max_target=200m
    create table t3(c1 int, c2 char(1000));
    insert into t3 select level, level from dual connect by level <= 50000;
    declare
      pat1     varchar2(1000);
      pat2     varchar2(1000);
      va       number;
    begin
      select ksppstvl into pat1
        from sys.xm$ksppi i, sys.xm$ksppcv v
        where i.indx = v.indx
        and i.ksppinm = '__pga_aggregate_target';
      for idx in 1 .. 1000000 loop
        -- try many patterns here!
        execute immediate 'select count(*) from t3 where 10 = mod('||idx||',10)+1' into va;
        if mod(idx, 100) = 0 then
          sys.dbms_system.ksdwrt(2, idx || 'th execution');
          for p in (select ksppinm, ksppstvl
              from sys.xm$ksppi i, sys.xm$ksppcv v
              where i.indx = v.indx
              and i.ksppinm in ('__shared_pool_size', '__db_cache_size', '__pga_aggregate_target')) loop
              sys.dbms_system.ksdwrt(2, p.ksppinm || ' = ' || p.ksppstvl);
          end loop;
          select ksppstvl into pat2
          from sys.xm$ksppi i, sys.xm$ksppcv v
          where i.indx = v.indx
          and i.ksppinm = '__pga_aggregate_target';
          if pat1 <> pat2 then
            sys.dbms_system.ksdwrt(2, 'yep, I got it! pat1=' || pat1 ||', pat2='||pat2);
            exit;
          end if;
        end if;
      end loop;
    end;
    /This test case showed expected and reasonable result, like following:
    100th execution
    __shared_pool_size = 92274688
    __db_cache_size = 16777216
    __pga_aggregate_target = 83886080
    200th execution
    __shared_pool_size = 92274688
    __db_cache_size = 16777216
    __pga_aggregate_target = 83886080
    300th execution
    __shared_pool_size = 88080384
    __db_cache_size = 20971520
    __pga_aggregate_target = 83886080
    400th execution
    __shared_pool_size = 92274688
    __db_cache_size = 16777216
    __pga_aggregate_target = 83886080
    500th execution
    __shared_pool_size = 88080384
    __db_cache_size = 20971520
    __pga_aggregate_target = 83886080
    1100th execution
    __shared_pool_size = 92274688
    __db_cache_size = 20971520
    __pga_aggregate_target = 83886080
    1200th execution
    __shared_pool_size = 92274688
    __db_cache_size = 37748736
    __pga_aggregate_target = 58720256
    yep, I got it! pat1=83886080, pat2=58720256Oracle continued being bounced between shared pool and buffer cache size, and about 1200th execution Oracle suddenly stole some memory from PGA target area to increase db cache size.
    (I'm still in dark age on this automatic memory target management of 11g. More research in need!)
    I think that this is very clear and natural behavior. I just want to point out that this would result in unwanted catastrophe under special cases, especially with some logic holes and bugs.
    ================================
    Dion Cho - Oracle Performance Storyteller
    http://dioncho.wordpress.com (english)
    http://ukja.tistory.com (korean)
    ================================

  • Can not configure Oracle 10g form  on oracle 11g client

    Hi
    I need to install oracle 10g form in my system .
    Here is my system
    1. OS --XP
    2. 32 Bit
    4. Already oracle 11g release client installed ( I think that create the problem )
    I tried to install oracle 10g form , it installed but can cont configure net manager for it , Always it point to 11g client and hence I could not configure .
    Also I tried install Oracle Forms first then 11g client , But  I got same issue .
    I think if  I created multiplr home one for 11g client and other for forms , it may work out .
    Please  help me
    Debashis

    While deploying the example 'VacationRequest' in the oracle complete guide for 11g, i got an exception like this
    "12:08:15 PM] Deploying Application...
    [12:11:16 PM] [Deployer:149191]Operation 'deploy' on application 'VacationRequestTaskFlow' is initializing on 'soa_server1'
    [12:11:24 PM] [Deployer:149034]An exception occurred for task [Deployer:149026]deploy application VacationRequestTaskFlow on soa_server1.: [Deployer:149145]Unable to contact 'bam_server1'. Deployment is deferred until 'bam_server1' becomes available.; nested exception is:
         java.rmi.UnknownHostException: Could not discover administration URL for server 'bam_server1'.
    [12:11:24 PM] [Deployer:149193]Operation 'deploy' on application 'VacationRequestTaskFlow' has failed on 'soa_server1'
    [12:11:24 PM] [Deployer:149034]An exception occurred for task [Deployer:149026]deploy application VacationRequestTaskFlow on soa_server1.: Failed to load webapp: 'VacationRequestTaskFlow.war'.
    [12:11:24 PM] Weblogic Server Exception: weblogic.application.ModuleException: Failed to load webapp: 'VacationRequestTaskFlow.war'
    [12:11:24 PM] Caused by: java.lang.ClassNotFoundException: oracle.adf.library.webapp.ResourceServlet
    [12:11:24 PM] See server logs or server console for more details.
    [12:11:24 PM] weblogic.application.ModuleException: Failed to load webapp: 'VacationRequestTaskFlow.war'
    [12:11:24 PM] #### Deployment incomplete. ####
    [12:11:24 PM] Deployment Failed"
    Can anyone help in this.

  • Oracle 11G - Update is very slow on View

    I have big trouble with some Update query on Oracle 11G.
    I have a set of tables (5) of identical structures and a view that consists in an UNION ALL of the 5 tables.
    None of this table contains more than 20 000 rows.
    Let's call the view V_INTE_NE. Each of the basic table has a PRIMARY KEY defined on 3 NUMBERS(10,0) -> INTE_REF / NE_REF / INSTANCE.
    Now, I get 6 rows in another table and I want to update my view from the data of this small table (let's call it SMALL). This table has the 3 columns INTE_REF / NE_REF / INSTANCE.
    When I try to join the two tables :
    SELECT * FROM T_INTE_NE T2
    WHERE EXISTS ( SELECT 1 FROM SMALL T1 WHERE T2.INTE_REF = T1.INTEREF AND T2.NE_REF = T1.NEREF AND T2.INTE_INST = T1.INSTANCE )
    I get the 6 lines in 0.037 seconds
    When I try to update the view (I have an INSTEAD OF trigger that does nothing (just return for testing even without modifying anything), I execute the following query :
    UPDATE T_INTE_NE T2
    SET INTE_STATE = -11 WHERE
    EXISTS ( SELECT 1 FROM SMALL T1 WHERE T2.INTE_REF = T1.INTEREF AND T2.NE_REF = T1.NEREF AND T2.INTE_INST = T1.INSTANCE )
    The 6 rows are updated (at least TRIGGER is called) in 20 seconds.
    However, in the execution plan, I can't see where Oracle takes time to achieve the query :
    Plan hash value: 907176690
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | UPDATE STATEMENT | | 6 | 36870 | 153 (1)| 00:00:02 |
    | 1 | UPDATE | T_INTE_NE | | | | |
    |* 2 | HASH JOIN RIGHT SEMI | | 6 | 36870 | 153 (1)| 00:00:02 |
    | 3 | TABLE ACCESS FULL | SMALL | 6 | 234 | 9 (0)| 00:00:01 |
    | 4 | VIEW | T_INTE_NE | 6 | 36636 | 143 (0)| 00:00:02 |
    | 5 | VIEW | X_V_T_INTE_NE | 6 | 18636 | 143 (0)| 00:00:02 |
    | 6 | UNION-ALL | | | | | |
    | 7 | TABLE ACCESS FULL| SECNODE1_T_INTE_NE | 1 | 3106 | 60 (0)| 00:00:01 |
    | 8 | TABLE ACCESS FULL| SECNODE2_T_INTE_NE | 1 | 3106 | 60 (0)| 00:00:01 |
    | 9 | TABLE ACCESS FULL| SECNODE3_T_INTE_NE | 1 | 3106 | 2 (0)| 00:00:01 |
    | 10 | TABLE ACCESS FULL| SECNODE4_T_INTE_NE | 1 | 3106 | 2 (0)| 00:00:01 |
    | 11 | TABLE ACCESS FULL| SECNODE5_T_INTE_NE | 1 | 3106 | 2 (0)| 00:00:01 |
    | 12 | TABLE ACCESS FULL| SYS_T_INTE_NE | 1 | 3106 | 17 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - access("T2"."INTE_REF"="T1"."INTEREF" AND "T2"."NE_REF"="T1"."NEREF" AND
    "T2"."INTE_INST"="T1"."INSTANCE")
    Note
    - dynamic sampling used for this statement (level=2)
    Statistics
    3 user calls
    0 physical read total bytes
    0 physical write total bytes
    0 spare statistic 3
    0 commit cleanout failures: cannot pin
    0 TBS Extension: bytes extended
    0 total number of times SMON posted
    0 SMON posted for undo segment recovery
    0 SMON posted for dropping temp segment
    0 segment prealloc tasks
    What could explain the difference ?
    I get exactly the same execution plan (when autotrace is ON).
    Furthermore, if I try to do the same update on each of the basic tables, I get the rows updated instantaneously.
    Is there any reason for avoiding this kind of query ?
    Any help would be greatly appreciated :-)
    Regards,
    Patrick

    Sorry for this, I lost myself in conjonctures and I didn't think I would have to explain the whole case.
    So, I wrote a small piece of PL/SQL that reproduces the same issue.
    It seems that my issue is not due to the UPDATE but to the use of the IN predicate.
    As you can see at the end of the script, I try to join the 2 tables using different technics.
    The first query is very fast, the second is very slow.
    I need the second one if I want to do any update.
    DROP TABLE Part1;
    DROP TABLE Part2;
    DROP TABLE Part3;
    DROP TABLE Part4;
    CREATE TABLE Part1 ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), PartId NUMBER(10, 0) DEFAULT( 1 ) NOT NULL, Data1 VARCHAR2(1000), X_Data2 VARCHAR2(2000) NULL, X_Data3 VARCHAR2(2000) NULL, CONSTRAINT PK_Part1 PRIMARY KEY( Key1, Key2, Key3 ) );
    CREATE TABLE Part2 ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), PartId NUMBER(10, 0) DEFAULT( 2 ) NOT NULL, Data1 VARCHAR2(1000), X_Data2 VARCHAR2(2000) NULL, X_Data3 VARCHAR2(2000) NULL, CONSTRAINT PK_Part2 PRIMARY KEY( Key1, Key2, Key3 ) );
    CREATE TABLE Part3 ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), PartId NUMBER(10, 0) DEFAULT( 3 ) NOT NULL, Data1 VARCHAR2(1000), X_Data2 VARCHAR2(2000) NULL, X_Data3 VARCHAR2(2000) NULL, CONSTRAINT PK_Part3 PRIMARY KEY( Key1, Key2, Key3 ) );
    CREATE TABLE Part4 ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), PartId NUMBER(10, 0) DEFAULT( 4 ) NOT NULL, Data1 VARCHAR2(1000), X_Data2 VARCHAR2(2000) NULL, X_Data3 VARCHAR2(2000) NULL, CONSTRAINT PK_Part4 PRIMARY KEY( Key1, Key2, Key3 ) );
    CREATE OR REPLACE FUNCTION Decrypt
    x_in IN VARCHAR2
    ) RETURN VARCHAR2
    AS
    x_out VARCHAR2(2000);
    BEGIN
    SELECT REVERSE( x_in ) INTO x_out FROM DUAL;
    RETURN ( x_out );
    END;
    CREATE OR REPLACE VIEW AllParts AS
    SELECT Key1, Key2, Key3, PartId, Data1, Decrypt( X_Data2 ) AS Data2, Decrypt( X_Data3 ) AS Data3 FROM Part1
    UNION ALL
    SELECT Key1, Key2, Key3, PartId, Data1, Decrypt( X_Data2 ) AS Data2, Decrypt( X_Data3 ) AS Data3 FROM Part2
    UNION ALL
    SELECT Key1, Key2, Key3, PartId, Data1, Decrypt( X_Data2 ) AS Data2, Decrypt( X_Data3 ) AS Data3 FROM Part3
    UNION ALL
    SELECT Key1, Key2, Key3, PartId, Data1, Decrypt( X_Data2 ) AS Data2, Decrypt( X_Data3 ) AS Data3 FROM Part4;
    DROP TABLE Small;
    CREATE TABLE Small ( Key1 NUMBER(10, 0), Key2 NUMBER(10, 0), Key3 NUMBER(10, 0), Data1 VARCHAR2(1000) );
    BEGIN
    DECLARE
    n_Key NUMBER(10, 0 ) := 0;
    BEGIN
    WHILE ( n_Key < 50000 )
    LOOP
    INSERT INTO Part1( Key1, Key2, Key3 )
    VALUES( n_Key, FLOOR( n_Key / 10 ), FLOOR( n_Key / 100 ) );
    INSERT INTO Part2( Key1, Key2, Key3 )
    VALUES( n_Key, FLOOR( n_Key / 10 ), FLOOR( n_Key / 100 ) );
    INSERT INTO Part3( Key1, Key2, Key3 )
    VALUES( n_Key, FLOOR( n_Key / 10 ), FLOOR( n_Key / 100 ) );
    INSERT INTO Part4( Key1, Key2, Key3 )
    VALUES( n_Key, FLOOR( n_Key / 10 ), FLOOR( n_Key / 100 ) );
    n_Key := n_Key + 1;
    END LOOP;
    INSERT INTO Small( Key1, Key2, Key3, Data1 ) VALUES ( 1000, 100, 10, 'Test 1000' );
    INSERT INTO Small( Key1, Key2, Key3, Data1 ) VALUES ( 3000, 300, 30, 'Test 3000' );
    INSERT INTO Small( Key1, Key2, Key3, Data1 ) VALUES ( 5000, 500, 50, 'Test 5000' );
    COMMIT;
    END;
    END;
    SELECT T2.*
    FROM Small T1, AllParts T2
    WHERE T2.Key1 = T1.Key1 AND T2.Key2 = T1.Key2 AND T2.Key3 = T1.Key3;
    SELECT T1.*
    FROM AllParts T1
    WHERE ( T1.Key1, T1.Key2, T1.Key3 ) IN ( SELECT T2.Key1, T2.Key2, T2.Key3 FROM Small T2 );

  • Oracle 11g Table function returns no records on first call

    Hello,
    On a Oracle 11g R2 I've a table function ( PIPELINED ) returning rows selected from a table.
    The first time the function is selected, in a session ( I've tried to disconnect and log in again ), it returns no rows.
    I've tried to log the call using DBMS_OUTPUT and from what I see the select on the table function returns no rows and no output is printed. So I presume Oracle is not calling the function.
    The same function on a similar environment ( same db versions, patches and database structure ) works fine. The second environment is a production environment so it has more memory and some other settings enabled.
    Does anyone know of settings that can relate to this behaviour ?
    Thanks in advance for the help.
    Regards,
    Stefano Muret

    Thank you for answering so fast.
    Here's the function code:
    FUNCTION template_parameters (iTemplate IN TEMPLATE_RAW_DATA.TMPL_ID%TYPE := NULL)
    RETURN table_type_tmpl_parameters PIPELINED
    IS
    li_exception INTEGER DEFAULT -20025;
    POUT_PARM TABLE_TYPE_TMPL_PARAMETERS;
    lt_parms table_type_tmpl_parms_raw;
    sParmCheck VARCHAR2(4000);
    iOccurrence INTEGER;
    BEGIN
    pOut_Parm := table_type_tmpl_parameters();
    pOut_Parm.EXTEND;
    select
    tmpl_id
    *,tmpl_name*
    *,replace(upper(trim(sql_out)),'[SCHEMA].')*
    *,UPPER(TRIM(out_tmpl_parms))*
    bulk collect into lt_parms
    from ref_templates
    where tmpl_id = NVL(iTemplate,tmpl_id)
    order by tmpl_id;
    FOR k IN 1..lt_parms.COUNT
    LOOP
    pOut_Parm(1).tmpl_id := lt_parms(k).tmpl_id;
    pOut_Parm(1).tmpl_name := lt_parms(k).tmpl_name;
    FOR i IN 1..2
    LOOP
    IF i = 1 THEN
    sParmCheck := lt_parms(k).sql_out;
    ELSE
    sParmCheck := lt_parms(k).sql_parms;
    END IF;
    iOccurrence := 1;
    *pOut_Parm(1).parameter_name := regexp_substr(sParmCheck,'\[[^\[]+\]',1,iOccurrence);*
    WHILE pOut_Parm(1).parameter_name IS NOT NULL
    LOOP
    PIPE ROW (pOut_Parm(1));
    iOccurrence := iOccurrence + 1;
    *pOut_Parm(1).parameter_name := regexp_substr(sParmCheck,'\[[^\[]+\]',1,iOccurrence);*
    END LOOP;
    END LOOP;
    END LOOP;
    RETURN;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(li_exception,SUBSTR(SQLERRM,1,1000));
    RETURN;
    END template_parameters;
    This function is part of a package.
    The data on both environments is the same.

  • Unpredictable problem using XMLTYPE in Oracle 11g?

    We recently upgraded from Oracle 10g to Oracle 11g, which caused some of our stored procedures to start acting funny.
    Our database stores BLOBs containing XML data in a table. We then asynchronously convert these BLOBs into XMLTYPE objects, and use them to perform operations in our database. This logic started failing when we moved to 11g.
    Our original code looked like this:
    PROCEDURE submitTpfdd(shipmentDataId IN VARCHAR2) AS
         shipmentData XMLTYPE;
      csid INTEGER;
      shipmentName VARCHAR(128);
      gk_namespaces VARCHAR(1024) := 'xmlns:a="http://my.app/1.0.0.0"';
    BEGIN
      SELECT NLS_CHARSET_ID('UTF8') INTO csid FROM dual;
      SELECT XMLTYPE(tf.shipmentData, csid)
        INTO shipmentData
        FROM SHIPQ.SHIPMENT_FILE tf
        WHERE tf.shipment_id = shipmentDataId;
      shipmentName := shipmentData.extract('/a:Shipment/shipmentName/text()', gk_namespaces).getStringVal();
      ... (more logic)
    END submitTpfdd;When we switched to 11g, this code started frequently failing with an "unsupported character set" error. It happens about half the time, and it's unpredictable. It will sometimes pass and sometimes fail, even if the same BLOB is being read both times. I haven't been able to reproduce the error with any of XMLTYPE's other constructors.
    Has anybody encountered similar behavior with the XMLTYPE in 11g? Should I submit a tracker?

    I have created a SQL program which can be run independently to reproduce the problem.
    DECLARE namespaces constant VARCHAR2(1024) := 'xmlns:a="http://morton.com/"';
    CURSOR cursor0(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor1(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor2(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor3(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor4(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor5(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor6(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor7(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor8(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    CURSOR cursor9(reeves XMLTYPE) IS
    SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
    bullock
    FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
    xml_clob CLOB := empty_clob;
    xml_blob BLOB := empty_blob;
    xml_varchar VARCHAR2(4000);
    xml_xmltype XMLTYPE;
    warning INTEGER;
    dest_offset INTEGER := 1;
    src_offset INTEGER := 1;
    lang_context INTEGER := 0;
    char_set INTEGER := nls_charset_id('UTF8');
    BEGIN
      dbms_lob.createtemporary(xml_clob, TRUE);
      dbms_lob.createtemporary(xml_blob, TRUE);
      dbms_lob.OPEN(xml_clob, dbms_lob.lob_readwrite);
      dbms_lob.OPEN(xml_blob, dbms_lob.lob_readwrite);
      xml_varchar := '<a:hopper xmlns:a="http://morton.com"/>';
      dbms_lob.writeappend(xml_clob, length(xml_varchar), xml_varchar);
      dbms_lob.converttoblob(xml_blob, xml_clob, dbms_lob.lobmaxsize, dest_offset, src_offset, char_set, lang_context, warning);
      xml_xmltype := XMLTYPE(xml_blob, char_set);
      FOR daniels IN cursor0(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor1(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor2(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor3(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor4(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor5(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor6(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor7(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor8(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
      FOR daniels IN cursor9(xml_xmltype)
      LOOP
        CONTINUE;
      END LOOP;
    END;If someone else could run this program and verify that it acts unpredictably, that would be helpful. I have submitted a metalink tracker but the person who is working the tracker is not able to duplicate the same behavior.

  • Object Invalidation in Oracle 11g R2

    Hi All,
    I found a distinct behaviour in oracle 11gR2 which is not even available in previous releases . Let me explain with an example.
    --creating a small table
    create table TEMPSAMPLE (COL1 VARCHAR2(10),COL2 VARCHAR2(10),COL3 VARCHAR2(15),COL4 VARCHAR2(15));
    -- Now Creating an Primary key index for table TEMPSAMPLE
    ALTER TABLE TEMPSAMPLE ADD CONSTRAINT PKTEMPSAMPLE PRIMARY KEY (COL1,COL2);
    ---CREATING A VIEW ON THE ABOVE TABLE
    CREATE OR REPLACE VIEW VWTEMPSAMPLE AS
    SELECT * FROM TEMPSAMPLE;
    -- CREATING A PACKAGE WHICH USES TEMPSAMPLE AND VWTEMPSAMPLE OBJECTS.
    CREATE OR REPLACE PACKAGE PKGSAMP AS
    VAL1 TEMPSAMPLE.COL1%TYPE;
    VAL2 CONSTANT TEMPSAMPLE.COL1%TYPE:='11';
    PROCEDURE VERIFYSAMP(INVAL IN NUMBER);
    END PKGSAMP;
    CREATE OR REPLACE PACKAGE BODY PKGSAMP IS
    PROCEDURE VERIFYSAMP(INVAL IN NUMBER)
    AS
    VAL1 TEMPSAMPLE.COL1%TYPE;
    VAL2 CONSTANT TEMPSAMPLE.COL1%TYPE:='11';
    BEGIN
    VAL1:='RAVI';
    FOR RC IN (SELECT * FROM VWTEMPSAMPLE)
    LOOP
    DBMS_OUTPUT.PUT_LINE('COL1 '||RC.COL1);
    DBMS_OUTPUT.PUT_LINE('COL2 '||RC.COL2);
    DBMS_OUTPUT.PUT_LINE('COL3 '||RC.COL3);
    END LOOP;
    INSERT INTO TEMPSAMPLE VALUES('REC05','RAVI','EEE','CK');
    DELETE FROM TEMPSAMPLE WHERE COL1='RECO1';
    UPDATE TEMPSAMPLE SET COL4='CKR' WHERE COL1='RECO2';
    DBMS_OUTPUT.PUT_LINE('VALUE IS '||INVAL);
    DBMS_OUTPUT.PUT_LINE('VALUE IS '||VAL1);
    END VERIFYSAMP;
    END PKGSAMP;
    --CREATING A PACKAGE PKGSAMP2 WHICH USES TEMPSAMPLE TABLE ITSELF
    CREATE OR REPLACE PACKAGE PKGSAMP2 AS
    VAL1 TEMPSAMPLE.COL1%TYPE;
    VAL2 CONSTANT TEMPSAMPLE.COL1%TYPE:='11';
    PROCEDURE VERIFYSAMP(INVAL IN NUMBER);
    END PKGSAMP2;
    CREATE OR REPLACE PACKAGE BODY PKGSAMP2 IS
    PROCEDURE VERIFYSAMP(INVAL IN NUMBER)
    AS
    VAL1 TEMPSAMPLE.COL1%TYPE;
    VAL2 CONSTANT TEMPSAMPLE.COL1%TYPE:='11';
    BEGIN
    VAL1:='RAVI';
    FOR RC IN (SELECT * FROM TEMPSAMPLE)
    LOOP
    DBMS_OUTPUT.PUT_LINE('COL1 '||RC.COL1);
    DBMS_OUTPUT.PUT_LINE('COL2 '||RC.COL2);
    DBMS_OUTPUT.PUT_LINE('COL3 '||RC.COL3);
    END LOOP;
    INSERT INTO TEMPSAMPLE VALUES('REC05','RAVI','EEE','CK');
    DELETE FROM TEMPSAMPLE WHERE COL1='RECO1';
    UPDATE TEMPSAMPLE SET COL4='CKR' WHERE COL1='RECO2';
    DBMS_OUTPUT.PUT_LINE('VALUE IS '||INVAL);
    DBMS_OUTPUT.PUT_LINE('VALUE IS '||VAL1);
    END VERIFYSAMP;
    END PKGSAMP2;
    -- OBJECT STATUS OF PACKAGES
    SELECT OBJECT_NAME,OBJECT_TYPE,STATUS FROM USER_OBJECTS WHERE OBJECT_NAME IN ('PKGSAMP','PKGSAMP2','VWTEMPSAMPLE');
    OBJECT_NAME   OBJECT_TYPE  STATUS*
    VWTEMPSAMPLE     VIEW     VALID
    PKGSAMP2     PACKAGE BODY     VALID
    PKGSAMP2     PACKAGE     VALID
    PKGSAMP     PACKAGE BODY     VALID
    PKGSAMP     PACKAGE     VALID
    Alter table TEMPSAMPLE DISABLE constraint PKTEMPSAMPLE KEEP INDEX;
    DROP INDEX PKTEMPSAMPLE;
    --OBJECT STATUS OF PACKAGES AFTER DROPPING INDEX
    SELECT OBJECT_NAME,OBJECT_TYPE,STATUS FROM USER_OBJECTS WHERE OBJECT_NAME IN ('PKGSAMP','PKGSAMP2','VWTEMPSAMPLE');
    OBJECT_NAME   OBJECT_TYPE  STATUS*
    VWTEMPSAMPLE     VIEW     INVALID
    PKGSAMP2     PACKAGE BODY     VALID
    PKGSAMP2     PACKAGE     VALID
    PKGSAMP      PACKAGE BODY     INVALID
    PKGSAMP     PACKAGE     VALID
    Alter table TEMPSAMPLE ENABLE constraint PKTEMPSAMPLE;
    As per the above process, if we observe that drop of index on a table arel lead to invalidation of view which* depends on that table  and all the objects which uses this view will also get invalidated.*
    The above invalidation is being occurred only in Oracle 11g R2, due to which we are facing the issue in our application.
    We got a procedure where we disable a constraint , drop a index and process the insertion/updation into the tables. After successfull insertion/updation, at finally we are enabling the constraint.
    This worked fine with previous releases of oracle 11g R2 , where as we recently migrated to 10g R2 which was leading to invalidation of all packages which uses the view , and in the application which uses previous db sessions are unable to access the invalidated package and raising an exception.
    Please provide the solution if any possible

    I tested the behavior in 10.2.0.4 and 11.2.0.3
    In 10.2.0.4, The view was valid if we disabled the constraint using the keep index option but it became invalid after dropping the index. SO i guess you are making them as unusable and rebuilding them after data load.
    in 11.2.0.3, The view became invalid as soon as we disabled the constraint using the keep index option.

  • Oracle 11g - Merge PL/SQL issue - Same code work in Oracle10g

    Below PL/SQL block stop working after Oracle11g upgrade, working fine in Oracle10g
    CREATE TABLE TMP_TABLE1 (P_PROVIDER NUMBER, P_ID NUMBER);
    CREATE TABLE TMP_TABLE2 (COL1 NUMBER, COL2 NUMBER);
    CREATE TABLE TMP_TABLE3 (COL3 NUMBER, COL4 NUMBER);
    BEGIN
    FOR i IN (SELECT p_provider p_provider, p_id p_id FROM tmp_table1)
    LOOP
    MERGE INTO TMP_TABLE2 T
    USING ( SELECT I.P_PROVIDER P_PROVIDER,
    I.P_ID P_ID FROM DUAL) DDD
    ON (T.COL1= DDD.P_PROVIDER AND T.COL2 = DDD.P_ID)
    WHEN NOT MATCHED THEN
    INSERT (COL1, COL2) VALUES (1, (SELECT x.COL4 FROM TMP_TABLE3 x WHERE x.COL4 = DDD.P_ID));
    END LOOP;
    END;
    Oracle 10g Version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Oracle 11g Version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE 11.2.0.2.0 Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 – Production
    Oracle11 g Error:
    Error at line 5
    ORA-06550: line 11, column 93:
    PL/SQL: ORA-00904: "DDD"."P_ID": invalid identifier
    ORA-06550: line 5, column 7:
    PL/SQL: SQL Statement ignored
    Script Terminated on line 5.
    Is there any patch/work around in Oracle 11g?
    Please advice
    Thank you
    Raj

    We had a similar issue when our organization upgraded to 11gR2.
    It looks like it boils down to a change Oracle made in regards to how it works with correlated subqueries within an insert statement.
    Anyway, this thread has a little more information:
    Merge Command in 10g vs 11g
    And it says to look at Metalink note 1109983.1 (which I can't seem to find).
    Anyway, a workaround in thread is suggests (which worked for us) to wrap the insert subquery around a dummy decode clause, and oddly it will work.
    eg:
    INSERT (COL1, COL2) VALUES (1, (decode(1,1,(SELECT x.COL4 FROM TMP_TABLE3 x WHERE x.COL4 = DDD.P_ID)) ) ) ;
    Quite a kludge, but at least it is an immediate fix to the problem, without having to rewrite anything.

Maybe you are looking for

  • Importing Sony DVDirect Video on DVD into FCE

    Hello...good wishes, I've been recording video from a Canon XL2 directly to DVD using a Sony VRD-VC20 DVDirect DVD Burner. When I try to import this video material into Final Cut Express, FCE does not recognize the format. Apple Support says that the

  • Wrap-up Time

    I have UCCX 9.02, is it possible to add a Button for Wrap up times. What I want is to basically, at the End the Call Give them 60 seconds (Wrap up Timer) to select a Wrap-Up button to type up there case codes then select End Wrap-up to start recievin

  • Can iWeb templates be modified?

    I last used iWeb to set up a travelogue in 2006. I have 3.0.4 ('09, I think). I may be remembering why I didn't use a template before--because I wanted something I couldn't get with the templates. Am I correct that I can't change a background or text

  • I have just updated to 3.6.4 and my browsers web pages only display in a narrow column in the centre of my screen.

    I have just updated to 3.6.4 and find that my browser web pages only display in a narrow column in the centre of my 16 inch screen. How can I stretch the web pages to fit my screen ? == This happened == Every time Firefox opened == After ungrading to

  • Link panel is not working in CS4

    The link panel does not show any links. I have tried various workspaces and panel options, rebooting, cursing. Nothing works. No links show. But the links do work. they are not borken. It is just the panel that is broken. Does anyone have any ideas h