MERGE hint

We have this merge statement that is created dynamically. If I use the hint in the merge clause (not the selects) it falls over ORA 12801 Error in parallel server query AND ORA 30563 Outer join operator (+) not allowed in select list.
Real environment has partition tables and 50M counts per partition but this breaks on non partition test tables with small record numbers as well.
Am I missing something???
MERGE /*+PARALLEL(m 4) */
INTO neil_Ar_Spcf_Fncl_Stat m
USING (SELECT CASE
WHEN rec_action_cde = 'I'
THEN ar_id * -1
ELSE ar_id
END ar_id,
fncl_stat_type_cde,
fncl_stat_cde
FROM (
SELECT ar_id, fncl_stat_type_cde, fncl_stat_cde, rec_action_cde,
COUNT (1) OVER (PARTITION BY ar_id, fncl_stat_type_cde, fncl_stat_cde)
rec_cnt
FROM (SELECT /*+PARALLEL(m 4) */
m.ar_id,
m.fncl_stat_type_cde,
m.fncl_stat_cde,
'U' rec_action_cde
FROM Ar_Spcf_Fncl_Stat m
WHERE m.start_dte <=
TO_DATE ('20050401', 'YYYYMMDD')
AND end_dte >=
TO_DATE ('20050401', 'YYYYMMDD')
AND fncl_stat_type_cde IN
('ACIRB', 'ACUIRB', 'ACSTD', 'ACUSTD')
and ar_id in (288387,18714055)
UNION ALL
SELECT 288387 ar_id, 'ASIRB' fncl_stat_type_cde,
'RTL' fncl_stat_cde,
'I' rec_action_cde
FROM dual
) t
GROUP BY ar_id, fncl_stat_type_cde, fncl_stat_cde, rec_action_cde) t
WHERE rec_cnt < 2) t
ON ( (CASE
WHEN m.ar_id < 0
THEN m.ar_id * -1
ELSE m.ar_id
END) = t.ar_id
AND m.fncl_stat_type_cde = t.fncl_stat_type_cde
AND m.fncl_stat_cde = t.fncl_stat_cde)
WHEN MATCHED THEN
UPDATE
SET m.end_dte = (TRUNC (TO_DATE ('20050401', 'YYYYMMDD') - 1))
WHEN NOT MATCHED THEN
INSERT (m.ar_id, m.fncl_stat_type_cde, m.fncl_stat_cde, m.start_dte,
m.end_dte)
VALUES (t.ar_id * -1, t.fncl_stat_type_cde, t.fncl_stat_cde,
TRUNC (TO_DATE ('20050401', 'YYYYMMDD')),
TO_DATE ('31-DEC-2999', 'DD-MON-YYYY'))

Sounds like a bug to me. There's a thread on Metalink Forum which seems to suggest this is a problem with the CBO. The OP had a different style of statement to yours but was receiving the same errors. This was 9.2.0.4.
A DBA response was that the CBO and its query rewrite was causing the issue:-
Compared execution plan against v8i database. There were some differences, namely in 8i first comes a full table scans and then outer join, but in case of 9i this Oracle is trying to push (+) into table select statement.
Setting optimizer_features_enabled=8.1.7.0 on 9i database resolved this.
Additionaly, reset optimizer to native 9i optimizer and changed
complexview_merging to false (it is true by default on 9i database) on session level is also helped. One can use hint NO_MERGE on statement level to achieve the same result.
There's no Oracle follow up on it, but I would suggest you try the NO_MERGE hint or add a dummy ROWNUM > 0 predicate to your in-line view.
It's also probably worth pointing out that until 9iR2, I'd never needed a NO_MERGE hint or any such thing, yet in 9.2.0.5 I found myself scattering them around everywhere...
Regards
Adrian

Similar Messages

  • Using Sort Merge Hint

    Hi,
    I'm trying to force oracle to use the sort merge using hints.
    Can anyone suggest why the below code is working correctly?
    Please see the explain plan.
    Regards, Chris.
    set autotrace on
    timing start
    select /*+ use_merge(e) */ e.fk, d.fk
    FROM girl d, boy e
    WHERE e.fk = d.fk;
    timing stop
    spool off
    set termout on
    SQL> timing stop
    Elapsed: 00:00:00.42
    SQL> spool off
    not spooling currently
    SQL> set termout on
    SQL> select * from girl WHERE fk = 1;
    PK NAME FK
    1 Hayley 1
    1 julie 1
    1 sian 1
    Execution Plan
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 3 | 114 | 3 |
    | 1 | TABLE ACCESS FULL| GIRL | 3 | 114 | 3 |
    Note
    - 'PLAN_TABLE' is old version
    Statistics
    5 recursive calls
    0 db block gets
    16 consistent gets
    0 physical reads
    0 redo size
    573 bytes sent via SQL*Net to client
    381 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed

    Thanks Dmytro, I'd just in fact solved the problem myself.
    THE SQL required both tables in the brackets.
    Thanks all for your help!

  • [oracle 10.2.0.4] My view is not merged

    Hi,
    I have a view which is not merged by the CBO. I mean the CBO decides to apply the filter predicate after the execution of the view.
    Here is the definition of the view
    CREATE OR REPLACE VIEW VUNSCP AS
    SELECT X.DASFM,X.COINT,X.NUCPT,X.RGCOD,X.RGCID,X.CODEV,X.CTDEV,X.CDVRF,X.TXCHJ,X.MTNLV,X.MTVDP,
           LEAD(X.MTNLV+X.MTVDP,1) OVER (PARTITION BY X.COINT,X.NUCPT,X.CDVRF,X.CTDEV,X.CODEV,X.RGCOD,X.RGCID  ORDER BY X.DASFM DESC),
           SUM(X.MTNLV) OVER (PARTITION BY X.COINT,X.CODEV,X.RGCOD)
    FROM SFMCPT XThe query is:
    explain plan for
    select * from VUNSCP where dasfm='30-apr-10';
    select * from table(dbms_xplan.display);
    Plan hash value: 2545326530
    | Id  | Operation           | Name   | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |        |    13M|  1529M|       |   195K  (1)| 00:39:11 |
    |*  1 |  VIEW               | VUNSCP |    13M|  1529M|       |   195K  (1)| 00:39:11 |
    |   2 |   WINDOW SORT       |        |    13M|   646M|  1996M|   195K  (1)| 00:39:11 |
    |   3 |    TABLE ACCESS FULL| SFMCPT |    13M|   646M|       | 27991   (4)| 00:05:36 |
    Predicate Information (identified by operation id):
       1 - filter("DASFM"='30-apr-10')You can see that a FTS is performed on SFMCPT (>1 million of rows) and that the filter predicate is applied only after the view has been instantiated.
    So the index on DASFM can't be used.
    This query is returning about 30 000 rows. We see on the plan that the CBO is mistaken beacause it reckons that there's going to be 13M of rows.
    If I add the filter predicate directly on the view'script I get the correct plan:
    explain plan for
    SELECT X.DASFM,X.COINT,X.NUCPT,X.RGCOD,X.RGCID,X.CODEV,X.CTDEV,X.CDVRF,X.TXCHJ,X.MTNLV,X.MTVDP,
           LEAD(X.MTNLV+X.MTVDP,1) OVER (PARTITION BY X.COINT,X.NUCPT,X.CDVRF,X.CTDEV,X.CODEV,X.RGCOD,X.RGCID ORDER BY X.DASFM DESC),
           SUM(X.MTNLV) OVER (PARTITION BY X.COINT,X.CODEV,X.RGCOD)
    FROM SFMCPT X where dasfm='30-apr-10';
    select * from table(dbms_xplan.display);
    Plan hash value: 1865390099
    | Id  | Operation                    | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |         | 14357 |   729K| 13271   (1)| 00:02:40 |
    |   1 |  WINDOW SORT                 |         | 14357 |   729K| 13271   (1)| 00:02:40 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| SFMCPT  | 14357 |   729K| 13269   (1)| 00:02:40 |
    |*  3 |    INDEX RANGE SCAN          | SFMCPT1 | 14357 |       |    67   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - access("DASFM"='30-apr-10')The index is now used and the rows estimated seem closer to the actual rows.
    I tried several things:
    - disabling the "OPTIMZER_COST_BASED_TRANSFORMATION" hidden parameter
    - use the MERGE hint
    - alter session set optimizer_features_enable = '9.2.0.8';
    All these workarounds don't work => I'm still getting the bad execution plan.
    According to Jonathan LEWIS' s book the 9i optimzer always merge views But here even if I set the optimizer_features_enable parameter to 9i the view is not merged.
    It's sure that the issue is due to the analytical functions but why ?
    Can please someone help me to understand what is going on ?
    Edited by: Ahmed AANGOUR on 5 mai 2010 08:41

    here is the 10053 trace file:
    /oracle/app/oracle/admin/UBIXPROD/udump/ubixprod_ora_24971_10053_optimizer_trace.trc
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORACLE_HOME = /oracle/app/oracle/10.2.0
    System name:    Linux
    Node name:      lin-ubi-test1.ubitrade.com
    Release:        2.6.9-78.0.1.ELsmp
    Version:        #1 SMP Tue Jul 22 18:01:05 EDT 2008
    Machine:        x86_64
    Instance name: UBIXPROD
    Redo thread mounted by this instance: 1
    Oracle process number: 26
    *** 2010-05-04 12:14:51.450
    *** ACTION NAME:() 2010-05-04 12:14:51.450
    *** MODULE NAME:([email protected] (TNS V1-V3)) 2010-05-04 12:14:51.450
    *** SERVICE NAME:(SYS$USERS) 2010-05-04 12:14:51.450
    *** SESSION ID:(135.1512) 2010-05-04 12:14:51.450
    Registered qb: SEL$1 0xa9e139a8 (PARSER)
      signature (): qb_name=SEL$1 nbfros=1 flg=0
        fro(0): flg=5 objn=297481 hint_alias="VUNSCP"@"SEL$1"
    Registered qb: SEL$2 0xa9e0bdd0 (PARSER)
      signature (): qb_name=SEL$2 nbfros=1 flg=0
        fro(0): flg=4 objn=265023 hint_alias="X"@"SEL$2"
    Predicate Move-Around (PM)
    PM: Considering predicate move-around in SEL$1 (#0).
    PM:   Checking validity of predicate move-around in SEL$1 (#0).
    CBQT: Validity checks failed for 3xakq94fcx4td.
    CVM: Considering view merge in query block SEL$1 (#0)
    CVM:   Checking validity of merging SEL$2 (#0)
    CVM: Considering view merge in query block SEL$2 (#0)
    CVM:     CVM bypassed: Window functions in this view
    CBQT: Validity checks failed for 3xakq94fcx4td.
    Subquery Unnest
    SU: Considering subquery unnesting in query block SEL$1 (#0)
    Set-Join Conversion (SJC)
    SJC: Considering set-join conversion in SEL$1 (#0).
    Set-Join Conversion (SJC)
    SJC: Considering set-join conversion in SEL$2 (#0).
    Predicate Move-Around (PM)
    PM: Considering predicate move-around in SEL$1 (#0).
    PM:   Checking validity of predicate move-around in SEL$1 (#0).
    PM:   Passed validity checks.
    FPD: Considering simple filter push in SEL$1 (#0)
    FPD:   Current where clause predicates in SEL$1 (#0) :
             "VUNSCP"."DASFM"='30-apr-10'
    kkogcp: try to generate transitive predicate from check constraints for SEL$1 (#0)
    predicates with check contraints: "VUNSCP"."DASFM"='30-apr-10'
    after transitive predicate generation: "VUNSCP"."DASFM"='30-apr-10'
    finally: "VUNSCP"."DASFM"='30-apr-10'
    JPPD:     JPPD bypassed: View not on right-side of outer join
    FPD: Considering simple filter push in SEL$2 (#0)
    FPD:   Current where clause predicates in SEL$2 (#0) :
             apadrv-start: call(in-use=2936, alloc=16344), compile(in-use=38784, alloc=44568)
    kkoqbc-start
                : call(in-use=2936, alloc=16344), compile(in-use=40472, alloc=44568)
    kkoqbc-subheap (create addr=0x2a9740c1f0)
    Current SQL statement for this session:
    EXPLAIN PLAN FOR select * from VUNSCP where dasfm='30-apr-10'
    Peeked values of the binds in SQL statement
    PARAMETERS USED BY THE OPTIMIZER
      PARAMETERS WITH ALTERED VALUES
      _pga_max_size                       = 262140 KB
      cursor_sharing                      = similar
      _optimizer_cost_based_transformation = off
    Column Usage Monitoring is ON: tracking level = 1
    QUERY BLOCK TEXT
    EXPLAIN PLAN FOR select * from VUNSCP where dasfm='30-apr-10'
    QUERY BLOCK SIGNATURE
    qb name was generated
    signature (optimizer): qb_name=SEL$2 nbfros=1 flg=0
      fro(0): flg=0 objn=265023 hint_alias="X"@"SEL$2"
    SYSTEM STATISTICS INFORMATION
      Using NOWORKLOAD Stats
      CPUSPEED: 2503 millions instruction/sec
      IOTFRSPEED: 4096 bytes per millisecond (default is 4096)
      IOSEEKTIM: 10 milliseconds (default is 10)
    BASE STATISTICAL INFORMATION
    Table Stats::
      Table: SFMCPT  Alias:  X
        #Rows: 13036040  #Blks:  122880  AvgRowLen:  358.00
    Index Stats::
      Index: SFMCPT1  Col#: 2 3 4 8 5 7 118
        LVLS: 2  #LB: 58758  #DK: 13013072  LB/K: 1.00  DB/K: 1.00  CLUF: 11983641.00
      Index: SFMCPT2  Col#: 1
        LVLS: 2  #LB: 30031  #DK: 13483987  LB/K: 1.00  DB/K: 1.00  CLUF: 2410599.00
      Index: SFMCPT3  Col#: 3 4 8 5 7 2 118
        LVLS: 2  #LB: 39065  #DK: 13013072  LB/K: 1.00  DB/K: 1.00  CLUF: 12583891.00
    SINGLE TABLE ACCESS PATH
      BEGIN Single Table Cardinality Estimation
      Table: SFMCPT  Alias: X
        Card: Original: 13036040  Rounded: 13036040  Computed: 13036040.00  Non Adjusted: 13036040.00
      END   Single Table Cardinality Estimation
      Access Path: TableScan
        Cost:  27991.05  Resp: 27991.05  Degree: 0
          Cost_io: 26881.00  Cost_cpu: 33334822147
          Resp_io: 26881.00  Resp_cpu: 33334822147
      Best:: AccessPath: TableScan
             Cost: 27991.05  Degree: 1  Resp: 27991.05  Card: 13036040.00  Bytes: 0
    OPTIMIZER STATISTICS AND COMPUTATIONS
    GENERAL PLANS
    Considering cardinality-based initial join order.
    Permutations for Starting Table :0
    Join order[1]:  SFMCPT[X]#0
    WiF sort
        SORT resource      Sort statistics
          Sort width:         766 Area size:     1048576 Max Area size:   134215680
          Degree:               1
          Blocks to Sort:  108528 Row size:           68 Total Rows:       13036040
          Initial runs:         7 Merge passes:        1 IO Cost / pass:      58786
          Total IO sort cost: 167314      Total CPU sort cost: 16584848017
          Total Temp space used: 2093966000
    Best so far: Table#: 0  cost: 195857.3183  card: 13036040.0000  bytes: 677874080
    (newjo-stop-1) k:0, spcnt:0, perm:1, maxperm:80000
    Number of join permutations tried: 1
        SORT resource      Sort statistics
          Sort width:         766 Area size:     1048576 Max Area size:   134215680
          Degree:               1
          Blocks to Sort:  108528 Row size:           68 Total Rows:       13036040
          Initial runs:         7 Merge passes:        1 IO Cost / pass:      58786
          Total IO sort cost: 167314      Total CPU sort cost: 16584848017
          Total Temp space used: 2093966000
    Final - All Rows Plan:  Best join order: 1
      Cost: 195857.3183  Degree: 1  Card: 13036040.0000  Bytes: 677874080
      Resc: 195857.3183  Resc_io: 194195.0000  Resc_cpu: 49919670164
      Resp: 195857.3183  Resp_io: 194195.0000  Resc_cpu: 49919670164
    kkoipt: Query block SEL$2 (#0)
    ******* UNPARSED QUERY IS *******
    SELECT "X"."DASFM" "DASFM","X"."COINT" "COINT","X"."NUCPT" "NUCPT","X"."RGCOD" "RGCOD","X"."RGCID" "RGCID","X"."CODEV" "CODEV","X"."CTDEV" "CTDEV","X"."CDVRF" "CDVRF","X"."TXCHJ" "TXCHJ","X"."MTNLV" "MTNLV","X"."MTVDP" "MTVDP",DECODE(COUNT(*) OVER ( PARTITION BY "X"."COINT","X"."CODEV","X"."RGCOD","X"."CTDEV","X"."NUCPT","X"."CDVRF","X"."RGCID" ORDER BY "X"."DASFM" DESC  ROWS  BETWEEN 1 FOLLOWING  AND 1 FOLLOWING ),1,FIRST_VALUE("X"."MTNLV"+"X"."MTVDP") OVER ( PARTITION BY "X"."COINT","X"."CODEV","X"."RGCOD","X"."CTDEV","X"."NUCPT","X"."CDVRF","X"."RGCID" ORDER BY "X"."DASFM" DESC  ROWS  BETWEEN 1 FOLLOWING  AND 1 FOLLOWING ),NULL) "MTUNS",SUM("X"."MTNLV") OVER ( PARTITION BY "X"."COINT","X"."CODEV","X"."RGCOD") "MTNLI" FROM "SFMCPT" "X"
    kkoqbc-subheap (delete addr=0x2a9740c1f0, in-use=11856, alloc=12408)
    kkoqbc-end
              : call(in-use=57760, alloc=81816), compile(in-use=41096, alloc=44568)
    kkoqbc-start
                : call(in-use=57760, alloc=81816), compile(in-use=41184, alloc=44568)
    kkoqbc-subheap (create addr=0x2a9746b058)
    QUERY BLOCK TEXT
    select * from VUNSCP where dasfm='30-apr-10'
    QUERY BLOCK SIGNATURE
    qb name was generated
    signature (optimizer): qb_name=SEL$1 nbfros=1 flg=0
      fro(0): flg=1 objn=297481 hint_alias="VUNSCP"@"SEL$1"
    SYSTEM STATISTICS INFORMATION
      Using NOWORKLOAD Stats
      CPUSPEED: 2503 millions instruction/sec
      IOTFRSPEED: 4096 bytes per millisecond (default is 4096)
      IOSEEKTIM: 10 milliseconds (default is 10)
    BASE STATISTICAL INFORMATION
    Table Stats::
      Table: VUNSCP  Alias: VUNSCP  (NOT ANALYZED)
        #Rows: 0  #Blks:  0  AvgRowLen:  0.00
    OPTIMIZER STATISTICS AND COMPUTATIONS
    GENERAL PLANS
    Considering cardinality-based initial join order.
    Permutations for Starting Table :
    Join order[1]:  VUNSCP[VUNSCP]#0
    Best so far: Table#: 0  cost: 195857.3183  card: 13036040.0000  bytes: 1603432920
    (newjo-stop-1) k:0, spcnt:0, perm:1, maxperm:80000
    Number of join permutations tried: 1
    Final - All Rows Plan:  Best join order: 1
      Cost: 195857.3183  Degree: 1  Card: 13036040.0000  Bytes: 1603432920
      Resc: 195857.3183  Resc_io: 194195.0000  Resc_cpu: 49919670164
      Resp: 195857.3183  Resp_io: 194195.0000  Resc_cpu: 49919670164
    kkoipt: Query block SEL$1 (#0)
    ******* UNPARSED QUERY IS *******
    SELECT "VUNSCP"."DASFM" "DASFM","VUNSCP"."COINT" "COINT","VUNSCP"."NUCPT" "NUCPT","VUNSCP"."RGCOD" "RGCOD","VUNSCP"."RGCID" "RGCID","VUNSCP"."CODEV" "CODEV","VUNSCP"."CTDEV" "CTDEV","VUNSCP"."CDVRF" "CDVRF","VUNSCP"."TXCHJ" "TXCHJ","VUNSCP"."MTNLV" "MTNLV","VUNSCP"."MTVDP" "MTVDP","VUNSCP"."MTUNS" "MTUNS","VUNSCP"."MTNLI" "MTNLI" FROM  (SELECT "X"."DASFM" "DASFM","X"."COINT" "COINT","X"."NUCPT" "NUCPT","X"."RGCOD" "RGCOD","X"."RGCID" "RGCID","X"."CODEV" "CODEV","X"."CTDEV" "CTDEV","X"."CDVRF" "CDVRF","X"."TXCHJ" "TXCHJ","X"."MTNLV" "MTNLV","X"."MTVDP" "MTVDP",DECODE(COUNT(*) OVER ( PARTITION BY "X"."COINT","X"."CODEV","X"."RGCOD","X"."CTDEV","X"."NUCPT","X"."CDVRF","X"."RGCID" ORDER BY "X"."DASFM" DESC  ROWS  BETWEEN 1 FOLLOWING  AND 1 FOLLOWING ),1,FIRST_VALUE("X"."MTNLV"+"X"."MTVDP") OVER ( PARTITION BY "X"."COINT","X"."CODEV","X"."RGCOD","X"."CTDEV","X"."NUCPT","X"."CDVRF","X"."RGCID" ORDER BY "X"."DASFM" DESC  ROWS  BETWEEN 1 FOLLOWING  AND 1 FOLLOWING ),NULL) "MTUNS",SUM("X"."MTNLV") OVER ( PARTITION BY "X"."COINT","X"."CODEV","X"."RGCOD") "MTNLI" FROM "SFMCPT" "X") "VUNSCP" WHERE "VUNSCP"."DASFM"='30-apr-10'
    kkoqbc-subheap (delete addr=0x2a9746b058, in-use=11544, alloc=12408)
    kkoqbc-end
              : call(in-use=63208, alloc=81816), compile(in-use=41688, alloc=44568)
    apadrv-end: call(in-use=63208, alloc=81816), compile(in-use=42872, alloc=44568)
    sql_id=3xakq94fcx4td.
    Current SQL statement for this session:
    EXPLAIN PLAN FOR select * from VUNSCP where dasfm='30-apr-10'
    ============
    Plan Table
    ============
    ---------------------------------------+-----------------------------------+
    | Id  | Operation            | Name    | Rows  | Bytes | Cost  | Time      |
    ---------------------------------------+-----------------------------------+
    | 0   | SELECT STATEMENT     |         |       |       |  191K |           |
    | 1   |  VIEW                | VUNSCP  |   12M | 1529M |  191K |  00:39:11 |
    | 2   |   WINDOW SORT        |         |   12M |  646M |  191K |  00:39:11 |
    | 3   |    TABLE ACCESS FULL | SFMCPT  |   12M |  646M |   27K |  00:06:36 |
    ---------------------------------------+-----------------------------------+
    Predicate Information:
    1 - filter("DASFM"='30-apr-10')Edited by: Ahmed AANGOUR on 5 mai 2010 08:43

  • Merge using schema.subquery

    there is a tiny error in the syntax illustration of the merge syntax
    Oracle® Database SQL Reference
    10g Release 2 (10.2)
    Part Number B14200-02
    MERGE
    Description of the illustration merge.gif
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/img/merge.gif
    MERGE [ hint ]
       INTO [ schema. ] { table | view } [ t_alias ]
       USING [ schema. ] { table | view | subquery }
         [ t_alias ]
       ON ( condition )
       [ merge_update_clause ]
       [ merge_insert_clause ]
       [ error_logging_clause ] ;schema.subquery is of course invalid, so I may suggest
    USING {  { [ schema. ] { table | view } } | subquery }
    [ t_alias ]
    Regards
    Laurent

    Hi Diana,
    Thanks a lot for your answer. Actually, I think you should use
    USING dml_table_expression_clause [ alias ]as for insert
    DML_table_expression_clause.gif
    SQL>
    SQL> merge into t1 using t2 partition (p1)
      2  on (t1.x=t2.x)
      3  when not matched then
      4    insert values(t2.x);
    0 rows merged.
    SQL>
    SQL> merge into t1 using t2 subpartition (p11)
      2  on (t1.x=t2.x)
      3  when not matched then
      4    insert values(t2.x);
    0 rows merged.
    SQL>
    SQL> merge into t1 using table(f)
      2  on (t1.x=column_value)
      3  when not matched then
      4    insert values(column_value);
    1 row merged.and review the text description of DML_TABLE_EXPRESSION clause
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/img_text/DML_table_expression_clause.htm
    ... because it is not very accurate
    { [ schema. ]
      { table
        [ { PARTITION (partition)
          | SUBPARTITION (subpartition)
        | @ dblink
      | { view | materialized view } [ @ dblink ]
    | ( subquery [ subquery_restriction_clause ] )
    | table_collection_expression
    }should be
    { [ schema. ]
      table
          { PARTITION (partition)
            | SUBPARTITION (subpartition)
          | @ dblink
      | { view | materialized view } [ @ dblink ]
    | ( subquery [ subquery_restriction_clause ] )
    |  table_collection_expression

  • Merge query

    actual syntax of merge stament is
    MERGE <hint> INTO <table_name>
    USING <table_view_or_query>
    ON (<condition>)
    WHEN MATCHED THEN <update_clause>
    WHEN NOT MATCHED THEN <insert_clause>;
    but is it possible or not.
    MERGE <hint> INTO <table_name>
    USING <table_view_or_query>
    ON (<condition>)
    WHEN MATCHED THEN <insert_clause into tab A>
    WHEN NOT MATCHED THEN <insert_clause into tab B>;

    but is it possible or not.
    MERGE <hint> INTO <table_name>
    USING <table_view_or_query>
    ON (<condition>)
    WHEN MATCHED THEN <insert_clause into tab A>
    WHEN NOT MATCHED THEN <insert_clause into tab B>;No, not direct.
    You can theoretically try to achieve it
    with update - trigger on tab A (+ dummy update of tab A
    in UPDATE-Caluse of merge), which inserts into tab B,
    but probably, it's better to search in direction INSERT ALL ...
    Message was edited by:
    Dmytro Dekhtyaryuk

  • Problem in merge

    Hi All,
    I've used iPhone 5s, iOS 8.1.3 This morning, I've tried to merge the calls between 2 parties. Both of them have been called by me but when trying to press "Merge Call" when both of them picked up the phone, "Merge Call" button was returned to enable like nothing acts before. I did click it more than 10 times on "Merge Call"
    Do they have any condition for Merge Call?
    Can we merge call with international call?
    anyone help me
    Thanks if someone can answer.

    Hi,
    Can I use insert statements in the when matched section of a merge statement.I don't think so..
    Merge Syntax says,
    MERGE <hint> INTO <table_name>
    USING <table_view_or_query>
    ON (<condition>)
    WHEN MATCHED THEN <update_clause>
    DELETE <where_clause>
    WHEN NOT MATCHED THEN <insert_clause>
    [LOG ERRORS <log_errors_clause> <reject limit <integer | unlimited>];Please clarify which p.id will be inserted if (p.id=i.id) do not match?
    You can use conditional insert.
    Twinkle

  • Getting ORA-00001 while using MERGE

    hi there,
    I am loading data from one Oracle table into another, using MERGE. My target table has a primary key constraint on TRANS_DATE, SEQ_NR and FILE_NAME. I have made sure that there are no duplicate rows in the the source table with regard to the target tables's primary key.
    The problem is that I am getting ORA-00001: Primary Key Violated ...
    my code is as follows:
    declare
    begin
    merge into fact_prepaidcalls_tb TARG
    using
    select
    nvl(fact_prepcustomers_tb.subscriberid,0) SUBSCRIBERID,
    accnum ACCNUM,
    sdrdate TRANS_DATE,
    TO_NUMBER(to_char(sdrdate,'yyyymmdd')) DIMDATEID,
    return_timeid(sdrdate) DIMTIMEID,
    return_peaktimeid(to_char(PAY_SDR.SDRDATE,'hh24miss'),SDRDATE) DIMPEAKTIMEID,
    nvl(dim_calltype.dimcalltypeid,0) DIMCALLTYPEID,
    sdrduration CHARGEDURATION,
    nvl(dim_tds_term.DIMTDStermid,9999) DIMTDSTERMID,
    calling CALLING,
    called CALLED,
    cparty CPARTY,
    freetimeused FREETIMEUSED,
    creditused CREDITUSED,
    creditrebate CREDITREBATE,
    servicetax SERVICETAX,
    surcharge SURCHARGE,
    follow FOLLOW,
    nvl(dim_call_location.dimcalllocationid,0) DIMCALLLOCATIONID,
    startbalance STARTBALANCE,
    priceoption PRICEOPTION,
    nvl(dim_cos.dimcosid,0) DIMCOSID,
    nvl(debitrate1,0) DEBITRATE1,
    debitrate2,
    prepaid.pay_sdr.region REGION,
    substr(file_name, instr(file_name,'cdr')) FILE_NAME,
    seq_nr SEQ_NR,
    SYSDATE LOADDATE,
    ORIGINNODE
    from prepaid.pay_sdr, dim_call_location, dim_calltype, dim_cos, dim_tds_term, fact_prepcustomers_tb
    where sdrdate >= to_date('10-Feb-2008 000000','dd-mon-rrrr hh24miss') and
    sdrdate <= to_date('10-Feb-2008 235959','dd-mon-rrrr hh24miss') and
    fact_prepcustomers_tb.msisdn = prepaid.pay_sdr.accnum and
    dim_calltype.calltypeid = prepaid.pay_sdr.type and
    dim_call_location.cellid = prepaid.pay_sdr.region and
    dim_cos.cosid = prepaid.pay_sdr.cos and
    dim_tds_term.termid = prepaid.pay_sdr.term
    ) SOUR
    on
    TARG.TRANS_DATE = SOUR.TRANS_DATE      and          
    TARG.SEQ_NR = SOUR.SEQ_NR      and          
    TARG.FILE_NAME = SOUR.FILE_NAME
    when not matched then
    --load fact data
    insert
    ( SUBSCRIBERID,
    ACCNUM,
    TRANS_DATE,
    DIMDATEID,
    DIMTIMEID,
    DIMPEAKTIMEID,
    DIMCALLTYPEID,
    CHARGEDURATION,
    DIMTDSTERMID,
    CALLING,
    CALLED,
    CPARTY,
    FREETIMEUSED,
    CREDITUSED,
    CREDITREBATE,
    SERVICETAX,
    SURCHARGE,
    FOLLOW,
    DIMCALLLOCATIONID,
    STARTBALANCE,
    PRICEOPTION,
    DIMCOSID,
    DEBITRATE1,
    DEBITRATE2,
    REGION,
    FILE_NAME,
    SEQ_NR,
    LOADDATE,
    CALLCHARGE,
    originnode)
    values
    ( SOUR.subscriberid,
    SOUR.ACCNUM,
    SOUR.TRANS_DATE,
    SOUR.DIMDATEID,
    SOUR.DIMTIMEID,
    SOUR.DIMPEAKTIMEID,
    SOUR.DIMCALLTYPEID,
    SOUR.CHARGEDURATION,
    SOUR.DIMTDSTERMID,
    SOUR.CALLING,
    SOUR.CALLED,
    SOUR.CPARTY,
    SOUR.FREETIMEUSED,
    SOUR.CREDITUSED,
    SOUR.CREDITREBATE,
    SOUR.SERVICETAX,
    SOUR.SURCHARGE,
    SOUR.FOLLOW,
    SOUR.DIMCALLLOCATIONID,
    SOUR.STARTBALANCE,
    SOUR.PRICEOPTION,
    SOUR.DIMCOSID,
    SOUR.DEBITRATE1,
    SOUR.DEBITRATE2,
    SOUR.REGION,
    SOUR.FILE_NAME,
    SOUR.SEQ_NR,
    SOUR.LOADDATE,
    SOUR.DEBITRATE1,
    SOUR.originnode);
    commit;
    end;

    Hi,
    you're missing WHEN MATCHED THEN <update_clause>
    {noformat}
    MERGE <hint> INTO <table_name>
    USING <table_view_or_query>
    ON (<condition>)
    WHEN MATCHED THEN <update_clause>
    DELETE <where_clause>
    WHEN NOT MATCHED THEN <insert_clause>
    [LOG ERRORS <log_errors_clause> <reject limit <integer | unlimited>];
    {noformat}
    Edited by: bobbydj on Sep 18, 2008 4:53 PM
    or you can try and add the primary key in the on condition

  • Please reply for the query tuning

    Hi, i am a beginner in oracle dba, I have to know if i have studied little bit about query tuning in ORACLE.
    I wanna know if i have the following query and its plan then how it can be tuned:
    QUERY:
              SELECT z.emplid ,h.first_name || ' ' || h.last_name  ,z.grade ,z.DEPTID ,z.LOCATION
                              FROM sysadm.ps_lnt_latestbu_vw z, sysadm.ps_personal_data h
                                    WHERE  z.empl_status ='A'    --index access
                                    AND z.emplid = h.emplid      --join
                                    and z.emplid not in   (select g.emplid from sysadm.ps_lnt_asn_skl_tbl g)    --join
                                    and z.Business_unit=
                                                               (      select l.lnt_subunit from sysadm.ps_position_data l where l.position_nbr in
                                                                                                    ( select b.position_nbr from sysadm.ps_job b,sysadm.psoprdefn y
                                                                                                              where b.effdt=(     select max(g.effdt) from sysadm.ps_job g
                                                                                                                                            where g.emplid=b.emplid           --join costs high
                                                                                                                                                and g.effdt<=SYSDATE)               --filter/index
                                                                                                                    and b.effseq=
                                                                                                                             (select max(h.effseq) from sysadm.ps_job h
                                                                                                                                       where h.emplid=b.emplid           --join costs high
                                                                                                                                      and h.effdt=b.effdt)               --join costs high
                                                                                                                and b.empl_rcd=0          --filter/index access
                                                                                                                and y.EMPLID=b.EMPLID  --join
                                                                                                                and y.OPRID='1112'   -- filter/index access
                                               order by z.emplid
                                            /AND its plan is:
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=6 Card=1 Bytes=64)
       1    0   SORT (ORDER BY) (Cost=6 Card=1 Bytes=64)
       2    1     NESTED LOOPS (ANTI) (Cost=4 Card=1 Bytes=64)
       3    2       NESTED LOOPS (Cost=3 Card=1 Bytes=56)
       4    3         VIEW OF 'PS_LNT_LATESTBU_VW' (Cost=2 Card=1 Bytes=31)
       5    4           UNION-ALL
       6    5             CONCATENATION
       7    6               TABLE ACCESS (BY INDEX ROWID) OF 'PS_POSITION_DATA' (Cost=5 Card=90 Bytes=1890)
       8    7                 NESTED LOOPS
       9    8                   NESTED LOOPS (Cost=275 Card=1 Bytes=90)
      10    9                     NESTED LOOPS (Cost=275 Card=1 Bytes=82)
      11   10                       TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=3 Card=1 Bytes=50)
      12   11                         INDEX (RANGE SCAN) OF 'PS2JOB' (NON-UNIQUE) (Cost=2 Card=1)
      13   12                           SORT (AGGREGATE)
      14   13                             FIRST ROW (Cost=3 Card=1 Bytes=19)
      15   14                               INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
      16   12                           SORT (AGGREGATE)
      17   16                             FIRST ROW (Cost=3 Card=1 Bytes=22)
      18   17                               INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
      19   10                       INDEX (UNIQUE SCAN) OF 'PS_EMPLOYMENT'(UNIQUE)
      20    9                     INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA' (UNIQUE)
      21    8                   INDEX (RANGE SCAN) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=5 Card=90)
      22    6               FILTER
      23   22                 NESTED LOOPS (Cost=275 Card=1 Bytes=90)
      24   23                   NESTED LOOPS (Cost=275 Card=1 Bytes=82)
      25   24                     NESTED LOOPS (Cost=275 Card=1 Bytes=71)
      26   25                       INDEX (FAST FULL SCAN) OF 'PS8POSITION_DATA' (NON-UNIQUE) (Cost=5 Card=90 Bytes=1890)
      27   25                       TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=3 Card=1 Bytes=50)
      28   27                         INDEX (RANGE SCAN) OF 'PS2JOB' (NON-UNIQUE) (Cost=2 Card=1)
      29   28                           SORT (AGGREGATE)
      30   29                             FIRST ROW (Cost=3 Card=1 Bytes=22)
      31   30                               INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
      32   28                           SORT (AGGREGATE)
      33   32                             FIRST ROW (Cost=3 Card=1 Bytes=19)
      34   33                               INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
      35   24                     INDEX (UNIQUE SCAN) OF 'PS_EMPLOYMENT' (UNIQUE)
      36   23                   INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA'(UNIQUE)
      37   22                 SORT (AGGREGATE)
      38   37                   FIRST ROW (Cost=2 Card=1 Bytes=17)
      39   38                     INDEX (RANGE SCAN (MIN/MAX)) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=2 Card=9000)
      40    5             FILTER
      41   40               NESTED LOOPS (Cost=751 Card=1 Bytes=191)
      42   41                 NESTED LOOPS (OUTER) (Cost=750 Card=1 Bytes=167)
      43   42                   NESTED LOOPS (OUTER) (Cost=749 Card=1 Bytes=143)
      44   43                     NESTED LOOPS (Cost=748 Card=1 Bytes=134)
      45   44                       NESTED LOOPS (Cost=748 Card=1 Bytes=123)
      46   45                         NESTED LOOPS (Cost=748 Card=1 Bytes=119)
      47   46                           NESTED LOOPS (Cost=747 Card=1 Bytes=98)
      48   47                             NESTED LOOPS (Cost=744 Card=1 Bytes=62)
      49   48                               NESTED LOOPS (Cost=744 Card=1Bytes=54)
      50   49                                 VIEW OF 'PS_LNTPRJOBSYSJRVW'(Cost=741 Card=1 Bytes=9)
      51   50                                   FILTER
      52   51                                     NESTED LOOPS (OUTER) (Cost=735 Card=1 Bytes=68)
      53   52                                       NESTED LOOPS (Cost=734Card=1 Bytes=51)
      54   53                                         NESTED LOOPS (Cost=734 Card=1 Bytes=43)
      55   54                                           TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=734 Card=1 Bytes=32)
      56   55                                             INDEX (RANGE SCAN) OF 'PSCJOB' (NON-UNIQUE) (Cost=206 Card=1013)
      57   54                                           INDEX (UNIQUE SCAN) OF 'PS_EMPLOYMENT' (UNIQUE)
      58   53                                         INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA' (UNIQUE)
      59   52                                       INDEX (RANGE SCAN) OF'PS_POSITION_DATA' (UNIQUE) (Cost=1 Card=1 Bytes=17)
      60   51                                     SORT (AGGREGATE)
      61   60                                       FIRST ROW (Cost=3 Card=1 Bytes=19)
      62   61                                         INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
      63   51                                     SORT (AGGREGATE)
      64   63                                       FIRST ROW (Cost=3 Card=1 Bytes=22)
      65   64                                         INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
      66   51                                     SORT (AGGREGATE)
      67   66                                       FIRST ROW (Cost=2 Card=1 Bytes=17)
      68   67                                         INDEX (RANGE SCAN (MIN/MAX)) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=2 Card=9000)
      69   49                                 TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=3 Card=1 Bytes=45)
      70   69                                   INDEX (RANGE SCAN) OF 'PSAJOB' (NON-UNIQUE) (Cost=2 Card=1)
      71   70                                     SORT (AGGREGATE)
      72   71                                       INDEX (RANGE SCAN) OF'PSAJOB' (NON-UNIQUE) (Cost=3 Card=1 Bytes=19)
      73   72                                         SORT (AGGREGATE)
      74   73                                           FIRST ROW (Cost=3Card=8 Bytes=88)
      75   74                                             INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=25963)
      76   70                                     SORT (AGGREGATE)
      77   76                                       FIRST ROW (Cost=3 Card=8 Bytes=88)
      78   77                                         INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=25963)
      79   48                               INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA' (UNIQUE)
      80   47                             TABLE ACCESS (BY INDEX ROWID) OF'PS_JOB' (Cost=3 Card=1 Bytes=36)
      81   80                               INDEX (RANGE SCAN) OF 'PSAJOB'(NON-UNIQUE) (Cost=2 Card=1)
      82   81                                 SORT (AGGREGATE)
      83   82                                   FIRST ROW (Cost=3 Card=1 Bytes=19)
      84   83                                     INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
      85   81                                 SORT (AGGREGATE)
      86   85                                   FIRST ROW (Cost=3 Card=1 Bytes=22)
      87   86                                     INDEX (RANGE SCAN (MIN/MAX)) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=207700)
      88   46                           INDEX (RANGE SCAN) OF 'PS8POSITION_DATA' (NON-UNIQUE) (Cost=1 Card=1 Bytes=21)
      89   45                         INDEX (UNIQUE SCAN) OF 'PS_BUS_UNIT_TBL_HR' (UNIQUE)
      90   44                       INDEX (UNIQUE SCAN) OF 'PS_EMPLOYMENT'(UNIQUE)
      91   43                     INDEX (RANGE SCAN) OF 'PS_POSITION_DATA'(UNIQUE) (Cost=1 Card=1 Bytes=9)
      92   42                   INDEX (FULL SCAN) OF 'PS0LOCATION_TBL' (NON-UNIQUE) (Cost=1 Card=1 Bytes=24)
      93   41                 INDEX (RANGE SCAN) OF 'PS0LOCATION_TBL' (NON-UNIQUE) (Cost=1 Card=1 Bytes=24)
      94   40               SORT (AGGREGATE)
      95   94                 FIRST ROW (Cost=2 Card=1 Bytes=17)
      96   95                   INDEX (RANGE SCAN (MIN/MAX)) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=2 Card=9000)
      97    4           TABLE ACCESS (BY INDEX ROWID) OF 'PS_POSITION_DATA' (Cost=2 Card=1 Bytes=13)
      98   97             NESTED LOOPS (Cost=9 Card=1 Bytes=19)
      99   98               VIEW OF 'VW_NSO_1' (Cost=5 Card=1 Bytes=6)
    100   99                 SORT (UNIQUE)
    101  100                   NESTED LOOPS (Cost=5 Card=1 Bytes=44)
    102  101                     TABLE ACCESS (BY INDEX ROWID) OF 'PSOPRDEFN' (Cost=2 Card=1 Bytes=14)
    103  102                       INDEX (UNIQUE SCAN) OF 'PS_PSOPRDEFN'(UNIQUE) (Cost=1 Card=1)
    104  101                     TABLE ACCESS (BY INDEX ROWID) OF 'PS_JOB' (Cost=3 Card=1 Bytes=30)
    105  104                       INDEX (RANGE SCAN) OF 'PSAJOB' (NON-UNIQUE) (Cost=2 Card=1)
    106  105                         SORT (AGGREGATE)
    107  106                           INDEX (RANGE SCAN) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=8 Bytes=128)
    108  105                         SORT (AGGREGATE)
    109  108                           INDEX (RANGE SCAN) OF 'PSAJOB' (NON-UNIQUE) (Cost=3 Card=1 Bytes=19)
    110   98               INDEX (RANGE SCAN) OF 'PS_POSITION_DATA' (UNIQUE) (Cost=1 Card=1)
    111    3         TABLE ACCESS (BY INDEX ROWID) OF 'PS_PERSONAL_DATA'(Cost=1 Card=1 Bytes=25)
    112  111           INDEX (UNIQUE SCAN) OF 'PS_PERSONAL_DATA' (UNIQUE)
    113    2       INDEX (RANGE SCAN) OF 'PS_LNT_ASN_SKL_TBL' (UNIQUE) (Cost=1 Card=10076 Bytes=80608)
    Statistics
             70  recursive calls
              0  db block gets
        1186931  consistent gets
           5660  physical reads
             60  redo size
            462  bytes sent via SQL*Net to client
            373  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
              0  rows processedMy thoughts for this is:
    1. NLJ high cost -- rewrite inner sub-query
    2. sort is done for each join for max function every time so,     therefore try use use sort merge hint
    3. h           alias has been referenced twice for table name.
    PLEASE TELL ME WHAT TO DO IF I AM ORACLE DBA.
    Thanks in advance.
    Edited by: user2060331 on Mar 25, 2010 9:17 AM
    Edited by: user2060331 on Mar 25, 2010 9:21 AM
    Edited by: user2060331 on Mar 25, 2010 9:32 AM
    Edited by: user2060331 on Mar 25, 2010 9:47 AM

    No it's not. You should see indentations for each level of the explain plan. You've lost all of it. It should look like this (not your query):
    PLAN_TABLE_OUTPUT
    | Id  | Operation                   | Name                | Rows  | Bytes | Cost  | Inst   |IN-OUT|
    |   0 | SELECT STATEMENT            |                     | 16116 |  2911K|   712 |        |      |
    |   1 |  FILTER                     |                     |       |       |       |        |      |
    |   2 |   CONNECT BY WITH FILTERING |                     |       |       |       |        |      |
    |   3 |    FILTER                   |                     |       |       |       |        |      |
    |   4 |     COUNT                   |                     |       |       |       |        |      |
    |   5 |      HASH JOIN RIGHT OUTER  |                     | 16116 |  2911K|   712 |        |      |
    |   6 |       REMOTE                | LSW_USR_GRP_XREF    |   518 | 13986 |     4 | MYPROJ~ | R->S |
    |   7 |       HASH JOIN RIGHT OUTER |                     | 16116 |  2486K|   707 |        |      |
    |   8 |        REMOTE               | LSW_USR_XREF        |   222 |  2886 |     4 | MYPROJ~ | R->S |
    |   9 |        HASH JOIN RIGHT OUTER|                     | 16116 |  2282K|   702 |        |      |
    |  10 |         TABLE ACCESS FULL   | MYPROJ_PROCESS_MAP   |   176 |  4752 |     4 |        |      |
    |  11 |         HASH JOIN OUTER     |                     | 16116 |  1857K|   698 |        |      |
    |  12 |          TABLE ACCESS FULL  | MYPROJ_MPPA | 16116 |  1243K|    71 |        |      |
    |  13 |          REMOTE             | LSW_TASK            | 80730 |  3074K|   625 | MYPROJ~ | R->S |
    |  14 |    HASH JOIN                |                     |       |       |       |        |      |
    |  15 |     CONNECT BY PUMP         |                     |       |       |       |        |      |
    |  16 |     COUNT                   |                     |       |       |       |        |      |
    |  17 |      HASH JOIN RIGHT OUTER  |                     | 16116 |  2911K|   712 |        |      |
    |  18 |       REMOTE                | LSW_USR_GRP_XREF    |   518 | 13986 |     4 | MYPROJ~ | R->S |
    |  19 |       HASH JOIN RIGHT OUTER |                     | 16116 |  2486K|   707 |        |      |
    |  20 |        REMOTE               | LSW_USR_XREF        |   222 |  2886 |     4 | MYPROJ~ | R->S |
    |  21 |        HASH JOIN RIGHT OUTER|                     | 16116 |  2282K|   702 |        |      |
    |  22 |         TABLE ACCESS FULL   | MYPROJ_PROCESS_MAP   |   176 |  4752 |     4 |        |      |
    |  23 |         HASH JOIN OUTER     |                     | 16116 |  1857K|   698 |        |      |
    |  24 |          TABLE ACCESS FULL  | MYPROJ_MPPA | 16116 |  1243K|    71 |        |      |
    |  25 |          REMOTE             | LSW_TASK            | 80730 |  3074K|   625 | MYPROJ~ | R->S |
    ---------------------------------------------------------------------------------------------------

  • Using hints in MERGE statement

    i have a merge statement
    in that statement for select clause i am using index hints
    can i use it
    whether that will increase the performance or the reverse will happen
    any comments

    Hints should always be your last option. First try tune the sql without using any hints, most of the cases you will be ok. Over time when the table statistics(ex. rows) changes considerably hints may be negative impact.

  • Two parallel hints in a merge statement

    I am not sure if using the parallel hint in such a way as below would be helpful in parallelizing the query run. Can a parallel hint be used for two different tables in a merge statement like mentioned below?
    MERGE INTO /*+ parallel (TABLE_A,8) */ TABLE_A  A
    USING( SELECT /*+ parallel (TABLE_B,8) */
                            col1,
                            col2
                  FROM TABLE_B
             )  B
    ON A.col1 = B.col1
    WHEN MATCHED THEN
    UPATE ....
    WHEN NOT MATCHED THEN
    INSERT ...
    I am using Oracle 10g.
    Thanks

    This does make sense (allowing for "someone else"'s observation about aliases); however MERGE is DML, so you couldn't get the merge phase working in parallel if you didn't also execute
    alter session enable parallel dml;
    Regards
    Jonathan Lewis

  • Questions on Merging Dis-similar Data Types...

    I am using Web-I version 11.5.8.834 (We do not use the Crystal Reports module, all of our reports are built with Web-I).
    I have two questions:
    Question 1: First I am attempting to create a report from two different universes and need to merge a dimension from each universe.  The two dimensions have similar data, but one is set up as a "string", and the other universe has the same data set up as a "number".  Our IT department creates and maintains the universes and I have requested that one of the dimension data type be changed to match the other, but I am told that other users have already set up reports using these dimensions and to change them at this point might cause a problem with their reports.  So my first question is: Can two separate dimensions be setup within a single universe, using the same data field, each having different data types (e.g., a field with numeric data be set up as a "string" and a second dimension be setup as a "number")?  If this works, I can make a recommendation to our IT department to do this and I will not have to resort to Question 2.  but just in case, here is Question 2:
    Question 2: I have two other dimensions that I might be able to use, but it requires creating a variable and "trimming" data off of each of the fields.  The first universe is a part number with three alpha characters followed by four numeric characters (PRT1234).  The second universe has a serial number, in which the first four characters match the last four characters of the other universe (1234-00111).  If I trim off the first three characters from the first universe using a variable (=right([Part_Number];4), and trim off the last six characters from the second universe using a variable (=left([Serial_Number],4), the variables will have matching data.  The second question is: Can variables be merged?  I've tried, but it isn't working so far.  If so, can someone give me some hints on how to do it?
    Edited by: Charles Norman on Aug 8, 2008 11:42 AM
    Edited by: Charles Norman on Aug 8, 2008 11:43 AM

    Charles,
    Can variables be merged?
    No, local variables cannot be merged.  The manipulation must be performed at the database level via Designer before the data comes across to the report.  As an aside, your IT deparatment can create "new" objects just for you, placed in the list under a separate sub-class that manipulates the data to your liking and will not upset other users who already built reports using the original columns of data.  I guess my point is that you can have multiple objects placed in your universe that derive from the same column in a given table -- user A has it per their flavor and user B has it per his flavor.
    Thanks,
    John

  • Query HINT help requested Pls.

    A query thus:
    SELECT equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    FROM v_stocked_equipment_inven_his vsdeih,
    v_stock_equipment_mod_man_list vsemml
    WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
    AND equipment_status_code IN
    ('ALL', 'AVA' )
    AND ec_end_date IS NULL
    AND eav_end_date IS NULL
    GROUP BY equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    HAVING COUNT (model_attribute_value_id) =
    (SELECT COUNT (*)
    FROM stock_equipment JOIN stock_equipment_attrib_value
    USING (stock_equipment_id)
    WHERE stock_equipment_id =
    vsemml.stock_equipment_id);
    has result :
    513 rows selected.
    Elapsed: 00:04:59.17
    Execution Plan
    Plan hash value: 3816309895
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 240 | 21120 | | 38010 (7)| 00:07:37 |
    |* 1 | FILTER | | | | | | |
    | 2 | HASH GROUP BY | | 240 | 21120 | | 38010 (7)| 00:07:37 |
    |* 3 | FILTER | | | | | | |
    |* 4 | HASH JOIN OUTER | | 23915 | 2055K| | 38006 (7)| 00:07:37 |
    |* 5 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
    | 6 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
    | 7 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    | 8 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 23915 | 1704K| | 37998 (7)| 00:07:36 |
    | 9 | HASH UNIQUE | | 23915 | 2989K| 6392K| 37998 (7)| 00:07:36 |
    |* 10 | HASH JOIN RIGHT OUTER | | 23915 | 2989K| | 37307 (7)| 00:07:28 |
    | 11 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
    |* 12 | HASH JOIN RIGHT OUTER | | 23915 | 2849K| | 37303 (7)| 00:07:28 |
    | 13 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
    |* 14 | HASH JOIN | | 23915 | 2615K| | 37297 (7)| 00:07:28 |
    | 15 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 16 | 128 | | 3 (0)| 00:00:01 |
    |* 16 | HASH JOIN | | 23915 | 2428K| | 37293 (7)| 00:07:28 |
    | 17 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    |* 18 | HASH JOIN | | 645K| 60M| | 37278 (7)| 00:07:28 |
    | 19 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
    |* 20 | HASH JOIN | | 5288K| 458M| 9M| 37180 (7)| 00:07:27 |
    | 21 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 297K| 6672K| | 784 (3)| 00:00:10 |
    |* 22 | HASH JOIN | | 7467K| 484M| 6328K| 5447 (5)| 00:01:06 |
    | 23 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
    |* 24 | HASH JOIN | | 380K| 22M| 4528K| 3235 (2)| 00:00:39 |
    |* 25 | HASH JOIN | | 140K| 2876K| | 563 (2)| 00:00:07 |
    | 26 | MERGE JOIN | | 281 | 3372 | | 6 (17)| 00:00:01 |
    | 27 | TABLE ACCESS BY INDEX ROWID| SITE_TYPE | 4 | 20 | | 2 (0)| 00:00:01 |
    | 28 | INDEX FULL SCAN | PK_SITE_TYPE | 4 | | | 1 (0)| 00:00:01 |
    |* 29 | SORT JOIN | | 281 | 1967 | | 4 (25)| 00:00:01 |
    | 30 | VIEW | index$_join$_016 | 281 | 1967 | | 3 (0)| 00:00:01 |
    |* 31 | HASH JOIN | | | | | | |
    | 32 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 33 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 34 | TABLE ACCESS FULL | LOCATION | 140K| 1232K| | 554 (2)| 00:00:07 |
    | 35 | TABLE ACCESS FULL | EQUIPMENT_CONFIGURATION | 380K| 15M| | 1460 (2)| 00:00:18 |
    | 36 | SORT AGGREGATE | | 1 | 6 | | | |
    | 37 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
    |* 38 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 39 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
    "STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
    "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
    "STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
    3 - filter(("EQUIPMENT_STATUS_CODE"='ALL' OR "EQUIPMENT_STATUS_CODE"='AVA') AND "EC_END_DATE" IS NULL AND "EAV_END_DATE"
    IS NULL)
    4 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID"(+))
    5 - access("SE"."MODEL_ID"="M"."MODEL_ID")
    10 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
    12 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
    14 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
    16 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID" AND
    "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    18 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID")
    20 - access("EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
    filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
    "EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
    IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
    22 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
    24 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
    25 - access("L"."SITE_ID"="S"."SITE_ID")
    29 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
    filter("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
    31 - access(ROWID=ROWID)
    38 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
    39 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
    Query altered to:
    =================
    SELECT equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    FROM v_stocked_equipment_inven_his vsdeih,
    v_stock_equipment_mod_man_list vsemml
    WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
    AND equipment_status_code = 'ALL'
    AND ec_end_date IS NULL
    AND eav_end_date IS NULL
    GROUP BY equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    HAVING COUNT (model_attribute_value_id) =
    (SELECT COUNT (*)
    FROM stock_equipment JOIN stock_equipment_attrib_value
    USING (stock_equipment_id)
    WHERE stock_equipment_id =
    vsemml.stock_equipment_id)
    union
    SELECT equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    FROM v_stocked_equipment_inven_his vsdeih,
    v_stock_equipment_mod_man_list vsemml
    WHERE vsemml.stock_equipment_id = vsdeih.stock_equipment_id(+)
    AND equipment_status_code = 'AVA'
    AND ec_end_date IS NULL
    AND eav_end_date IS NULL
    GROUP BY equipment_id,
    vsemml.stock_equipment_id,
    game_ware_id
    HAVING COUNT (model_attribute_value_id) =
    (SELECT COUNT (*)
    FROM stock_equipment JOIN stock_equipment_attrib_value
    USING (stock_equipment_id)
    WHERE stock_equipment_id =
    vsemml.stock_equipment_id);
    Results in:
    513 rows selected.
    Elapsed: 00:00:07.40
    Execution Plan
    Plan hash value: 3317078232
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 2 | 176 | | 6431 (51)| 00:01:18 |
    | 1 | SORT UNIQUE | | 2 | 176 | | 6431 (51)| 00:01:18 |
    | 2 | UNION-ALL | | | | | | |
    |* 3 | FILTER | | | | | | |
    | 4 | HASH GROUP BY | | 1 | 88 | | 3216 (2)| 00:00:39 |
    |* 5 | HASH JOIN | | 95 | 8360 | | 3214 (2)| 00:00:39 |
    |* 6 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
    | 7 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
    | 8 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    | 9 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 95 | 6935 | | 3207 (2)| 00:00:39 |
    | 10 | HASH UNIQUE | | 95 | 12160 | | 3207 (2)| 00:00:39 |
    |* 11 | HASH JOIN RIGHT OUTER | | 95 | 12160 | | 3206 (2)| 00:00:39 |
    | 12 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
    |* 13 | HASH JOIN OUTER | | 95 | 11590 | | 3202 (2)| 00:00:39 |
    |* 14 | HASH JOIN | | 95 | 10640 | | 3196 (2)| 00:00:39 |
    | 15 | TABLE ACCESS FULL | SITE_TYPE | 4 | 20 | | 3 (0)| 00:00:01 |
    |* 16 | HASH JOIN | | 95 | 10165 | | 3193 (2)| 00:00:39 |
    | 17 | VIEW | index$_join$_021 | 281 | 1967 | | 3 (0)| 00:00:01 |
    |* 18 | HASH JOIN | | | | | | |
    | 19 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 20 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 21 | NESTED LOOPS | | 95 | 9500 | | 3189 (2)| 00:00:39 |
    |* 22 | HASH JOIN | | 96 | 8736 | 4440K| 3093 (2)| 00:00:38 |
    |* 23 | HASH JOIN | | 56789 | 3771K| | 1679 (2)| 00:00:21 |
    |* 24 | HASH JOIN | | 2894 | 178K| | 1273 (1)| 00:00:16 |
    | 25 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
    |* 26 | HASH JOIN | | 2894 | 158K| | 1271 (1)| 00:00:16 |
    | 27 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    |* 28 | TABLE ACCESS BY INDEX ROWID| EQUIPMENT_CONFIGURATION | 1279 | 53718 | | 1265 (1)| 00:00:16 |
    | 29 | NESTED LOOPS | | 1860 | 93000 | | 1268 (1)| 00:00:16 |
    |* 30 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 1 | 8 | | 3 (0)| 00:00:01 |
    |* 31 | INDEX RANGE SCAN | XIF3EQUIPMENT_CONFIGURATION | 23796 | | | 48 (3)| 00:00:01 |
    | 32 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
    |* 33 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 242K| 5451K| | 785 (3)| 00:00:10 |
    | 34 | TABLE ACCESS BY INDEX ROWID | LOCATION | 1 | 9 | | 1 (0)| 00:00:01 |
    |* 35 | INDEX UNIQUE SCAN | PK_LOCATION | 1 | | | 0 (0)| 00:00:01 |
    | 36 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
    | 37 | SORT AGGREGATE | | 1 | 6 | | | |
    | 38 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
    |* 39 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 40 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 41 | FILTER | | | | | | |
    | 42 | HASH GROUP BY | | 1 | 88 | | 3216 (2)| 00:00:39 |
    |* 43 | HASH JOIN | | 95 | 8360 | | 3214 (2)| 00:00:39 |
    |* 44 | HASH JOIN | | 42 | 630 | | 7 (15)| 00:00:01 |
    | 45 | TABLE ACCESS FULL | MODEL | 31 | 279 | | 3 (0)| 00:00:01 |
    | 46 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    | 47 | VIEW | V_STOCKED_EQUIPMENT_INVEN_HIS | 95 | 6935 | | 3207 (2)| 00:00:39 |
    | 48 | HASH UNIQUE | | 95 | 12160 | | 3207 (2)| 00:00:39 |
    |* 49 | HASH JOIN RIGHT OUTER | | 95 | 12160 | | 3206 (2)| 00:00:39 |
    | 50 | TABLE ACCESS FULL | GAME_WARE | 325 | 1950 | | 3 (0)| 00:00:01 |
    |* 51 | HASH JOIN OUTER | | 95 | 11590 | | 3202 (2)| 00:00:39 |
    |* 52 | HASH JOIN | | 95 | 10640 | | 3196 (2)| 00:00:39 |
    | 53 | TABLE ACCESS FULL | SITE_TYPE | 4 | 20 | | 3 (0)| 00:00:01 |
    |* 54 | HASH JOIN | | 95 | 10165 | | 3193 (2)| 00:00:39 |
    | 55 | VIEW | index$_join$_044 | 281 | 1967 | | 3 (0)| 00:00:01 |
    |* 56 | HASH JOIN | | | | | | |
    | 57 | INDEX FAST FULL SCAN | PK_SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 58 | INDEX FAST FULL SCAN | XIF1SITE | 281 | 1967 | | 1 (0)| 00:00:01 |
    | 59 | NESTED LOOPS | | 95 | 9500 | | 3189 (2)| 00:00:39 |
    |* 60 | HASH JOIN | | 96 | 8736 | 4440K| 3093 (2)| 00:00:38 |
    |* 61 | HASH JOIN | | 56789 | 3771K| | 1679 (2)| 00:00:21 |
    |* 62 | HASH JOIN | | 2894 | 178K| | 1273 (1)| 00:00:16 |
    | 63 | INDEX FULL SCAN | XPKSTOCK_EQUIPMENT_ATTRIB_VAL | 42 | 294 | | 1 (0)| 00:00:01 |
    |* 64 | HASH JOIN | | 2894 | 158K| | 1271 (1)| 00:00:16 |
    | 65 | TABLE ACCESS FULL | STOCK_EQUIPMENT | 42 | 252 | | 3 (0)| 00:00:01 |
    |* 66 | TABLE ACCESS BY INDEX ROWID| EQUIPMENT_CONFIGURATION | 1279 | 53718 | | 1265 (1)| 00:00:16 |
    | 67 | NESTED LOOPS | | 1860 | 93000 | | 1268 (1)| 00:00:16 |
    |* 68 | TABLE ACCESS FULL | EQUIPMENT_STATUS | 1 | 8 | | 3 (0)| 00:00:01 |
    |* 69 | INDEX RANGE SCAN | XIF3EQUIPMENT_CONFIGURATION | 23796 | | | 48 (3)| 00:00:01 |
    | 70 | INDEX FAST FULL SCAN | PK_EQUIPMENT_CONFIGURATION | 380K| 1859K| | 398 (3)| 00:00:05 |
    |* 71 | TABLE ACCESS FULL | EQUIPMENT_ATTRIBUTE_VALUE | 242K| 5451K| | 785 (3)| 00:00:10 |
    | 72 | TABLE ACCESS BY INDEX ROWID | LOCATION | 1 | 9 | | 1 (0)| 00:00:01 |
    |* 73 | INDEX UNIQUE SCAN | PK_LOCATION | 1 | | | 0 (0)| 00:00:01 |
    | 74 | TABLE ACCESS FULL | GAMESET | 825 | 8250 | | 5 (0)| 00:00:01 |
    | 75 | SORT AGGREGATE | | 1 | 6 | | | |
    | 76 | NESTED LOOPS | | 1 | 6 | | 0 (0)| 00:00:01 |
    |* 77 | INDEX UNIQUE SCAN | XPKSTOCK_EQUIPMENT | 1 | 3 | | 0 (0)| 00:00:01 |
    |* 78 | INDEX RANGE SCAN | XIF1STOCK_EQUIPMENT_ATTRIB_VAL | 1 | 3 | | 0 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    3 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
    "STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
    "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
    "STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
    5 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID")
    6 - access("SE"."MODEL_ID"="M"."MODEL_ID")
    11 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
    13 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
    14 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
    16 - access("L"."SITE_ID"="S"."SITE_ID")
    18 - access(ROWID=ROWID)
    22 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID" AND
    "EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
    filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
    "EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
    IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
    23 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
    24 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    26 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID")
    28 - filter("EC"."END_DATE" IS NULL)
    30 - filter("ES"."EQUIPMENT_STATUS_CODE"='ALL')
    31 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
    33 - filter("EAV"."END_DATE" IS NULL)
    35 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
    39 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
    40 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
    41 - filter(COUNT("MODEL_ATTRIBUTE_VALUE_ID")= (SELECT COUNT(*) FROM "STOCK_EQUIPMENT_ATTRIB_VALUE"
    "STOCK_EQUIPMENT_ATTRIB_VALUE","STOCK_EQUIPMENT" "STOCK_EQUIPMENT" WHERE "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1 AND
    "STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID" AND
    "STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B2))
    43 - access("SE"."STOCK_EQUIPMENT_ID"="VSDEIH"."STOCK_EQUIPMENT_ID")
    44 - access("SE"."MODEL_ID"="M"."MODEL_ID")
    49 - access("GS"."GAME_WARE_ID"="GW"."GAME_WARE_ID"(+))
    51 - access("EC"."GAMESET_ID"="GS"."GAMESET_ID"(+))
    52 - access("S"."SITE_TYPE_ID"="ST"."SITE_TYPE_ID")
    54 - access("L"."SITE_ID"="S"."SITE_ID")
    56 - access(ROWID=ROWID)
    60 - access("MODEL_ATTRIBUTE_VALUE_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."MODEL_ATTRIBUTE_VALUE_ID" AND
    "EC"."EQUIPMENT_ID"="EAV"."EQUIPMENT_ID")
    filter("EAV"."START_DATE">="EC"."START_DATE" AND ("EAV"."END_DATE" IS NULL AND "EC"."END_DATE">="EAV"."START_DATE" OR
    "EC"."END_DATE" IS NULL OR "EAV"."END_DATE"<="EC"."END_DATE") OR "EC"."START_DATE">="EAV"."START_DATE" AND ("EC"."END_DATE"
    IS NULL AND "EAV"."END_DATE">="EC"."START_DATE" OR "EAV"."END_DATE" IS NULL OR "EC"."END_DATE"<="EAV"."END_DATE"))
    61 - access("EC"."EQUIPMENT_ID"="EC"."EQUIPMENT_ID")
    62 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    64 - access("EC"."MODEL_ID"="STOCK_EQUIPMENT"."MODEL_ID")
    66 - filter("EC"."END_DATE" IS NULL)
    68 - filter("ES"."EQUIPMENT_STATUS_CODE"='AVA')
    69 - access("EC"."EQUIPMENT_STATUS_ID"="ES"."EQUIPMENT_STATUS_ID")
    71 - filter("EAV"."END_DATE" IS NULL)
    73 - access("EC"."LOCATION_ID"="L"."LOCATION_ID")
    77 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"=:B1)
    78 - access("STOCK_EQUIPMENT"."STOCK_EQUIPMENT_ID"="STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID")
    filter("STOCK_EQUIPMENT_ATTRIB_VALUE"."STOCK_EQUIPMENT_ID"=:B1)
    5 minutes reduced to 7 seconds.!!
    THE QUESTION.
    Which (and where) query hint do I use to get the FIRST query to use the execution plan "method" of the second -
    IE: To still perform well when a IN-LIST is used instead of EQUALS.
    Technical:
    Oracle 10.2.0.2 EE on Solaris 8, 64 bit.
    Please help.
    Thank you.
    Below is the code of the referenced views for clarity.
    CREATE OR REPLACE FORCE VIEW etrak.v_stocked_equipment_inven_his (stock_equipment_id,
    equipment_id,
    model_id,
    gameset_id,
    gameset_is_active,
    game_ware_id,
    game_ware_is_active,
    equipment_status_code,
    ec_start_date,
    ec_end_date,
    eav_start_date,
    eav_end_date,
    model_attribute_value_id,
    site_id,
    is_store
    AS
    SELECT DISTINCT stock_equipment_id, equipment_id, model_id, gameset_id,
    gameset_is_active, game_ware_id, game_ware_is_active,
    equipment_status_code, ec_start_date, ec_end_date,
    eav_start_date, eav_end_date, model_attribute_value_id,
    site_id, is_store
    FROM (SELECT stock_equipment_id, equipment_id, model_id,
    gameset_id, gameset_is_active, game_ware_id,
    game_ware_is_active, equipment_status_code,
    ec_start_date, ec_end_date, eav_start_date,
    eav_end_date, model_attribute_value_id, site_id,
    is_store
    FROM (SELECT DISTINCT equipment_id, model_id,
    gameset_id, gameset_is_active,
    game_ware_id, game_ware_is_active,
    equipment_status_code,
    model_attribute_value_id,
    ec_start_date, ec_end_date,
    eav_start_date, eav_end_date,
    site_id, is_store
    FROM (SELECT ec.equipment_id,
    ec.model_id,
    gs.gameset_id,
    gs.active_flag
    AS gameset_is_active,
    gw.game_ware_id,
    gw.active_flag
    AS game_ware_is_active,
    es.equipment_status_code,
    ec.start_date
    AS ec_start_date,
    ec.end_date
    AS ec_end_date,
    l.site_id, st.is_store
    FROM equipment_configuration ec,
    equipment_status es,
    LOCATION l,
    site s,
    site_type st,
    gameset gs,
    game_ware gw
    WHERE ec.equipment_status_id =
    es.equipment_status_id
    AND ec.gameset_id = gs.gameset_id(+)
    AND gs.game_ware_id = gw.game_ware_id(+)
    AND ec.location_id =
    l.location_id
    AND l.site_id = s.site_id
    AND s.site_type_id =
    st.site_type_id)
    JOIN
    (SELECT ec.equipment_id,
    model_attribute_value_id,
    eav.start_date
    AS eav_start_date,
    eav.end_date
    AS eav_end_date
    FROM equipment_configuration ec,
    equipment_attribute_value eav
    WHERE ec.equipment_id =
    eav.equipment_id)
    USING (equipment_id)
    WHERE ( eav_start_date >=
    ec_start_date
    AND ( ( eav_end_date IS NULL
    AND ec_end_date >=
    eav_start_date
    OR ec_end_date IS NULL
    OR eav_end_date <=
    ec_end_date
    OR ( ec_start_date >=
    eav_start_date
    AND ( ( ec_end_date IS NULL
    AND eav_end_date >=
    ec_start_date
    OR eav_end_date IS NULL
    OR ec_end_date <=
    eav_end_date
    JOIN
    (SELECT stock_equipment_id, model_id,
    model_attribute_value_id
    FROM stock_equipment JOIN stock_equipment_attrib_value
    USING (stock_equipment_id)
    ) USING (model_id,
    model_attribute_value_id)
    CREATE OR REPLACE FORCE VIEW etrak.v_stock_equipment_mod_man_list (stock_equipment_id,
    stock_equipment_code,
    model_id,
    model_name,
    model_type_id,
    model_type_code,
    model_type_name,
    man_id,
    man_name
    AS
    SELECT se.stock_equipment_id, se.stock_equipment_code, m.model_id,
    m.model_name, mt.model_type_id, mt.model_type_code,
    mt.model_type_name, ma.man_id, ma.man_name
    FROM stock_equipment se, model m, model_type mt, manufacturer ma
    WHERE se.model_id = m.model_id
    AND m.model_type_id = mt.model_type_id
    AND m.man_id = ma.man_id;

    What also makes it difficult to read is the lack of formatting tags ([code][/code] or [pre][/pre]) so that we can actually read the code and execution plans.
    I'm not going to trawl through formatting all that myself just to try and see what the differences are between query 1 and query 2.
    Also bear in mind that when query 2 ran, the data may have been cached and so there is less physical I/O required.
    You don't really want to use any hints to cause re-use of execution plans from 1 query to a different query (like I said, I don't know how different they are). What you want to do is determine what poor SQL coding is making the first query slow and fix it.

  • How can i merge different apple id?

    DEAR:
         I am a fresh man to apple's product. Now, i got ipad air & ipad mini & mbp. but each of the three devices has different apple id...
         at the beginning, I didn't realize it is a problem until i use icloud and app purchase.
         i tried new apple id, but seems that my device was marked by old apple id, so, i can't download iLife & iWork free with new apple id...
         so, how can i let apple know i want to change the associated apple id with my device? If that, i can download ILife & iWork for free with new apple id.
         when i want to enable "books in 'auto download' page", i got a hint : "you can auto-dwoanload puchases on this device with just one apple id every 90 days. you cannot associated this device with a different apple id for 84 days.
         does it mean: after 84 days, i can use new apple id to download iLife & iWork for free?
    Ice.
    best regards.

    You cannot merge Apple IDs. You can only stop using them. Anything purchased under an Apple ID is always tied to that Apple ID. It cannot be transferred to another Apple ID.

  • Failed to revert logical volume group while merging partition

    Hi All,
    Previously, on my macbook pro, I partitioned my disk for win7 for my dual operation system and only left 120 GB for OS, now I want to delete win7 and return disk space to OS. Currently my OS is yosemite.
    I have already deleted disk space for win7 and merged it back to disk0s3. And, I had a problem to merge disk0s2 with disk0s3.
    I was told it is because I need to revet my Logical Volume Group. I am blocked at reverting it.
    This is my disk info:
    rescomp-14-251133:~ rico$ diskutil list; diskutil  cs list
    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                        EFI EFI                     209.7 MB   disk0s1
       2:          Apple_CoreStorage                         119.3 GB   disk0s2
       3:                  Apple_HFS Recovery HD             380.6 GB   disk0s3
    /dev/disk1
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:                  Apple_HFS Macintosh HD           *119.0 GB   disk1
                                     Logical Volume on disk0s2
                                     CC457129-6FE9-41A0-B0D2-F547F21A7555
                                     Unencrypted
    CoreStorage logical volume groups (1 found)
    |
    +-- Logical Volume Group F454017F-C531-43BA-B270-E2058E05BFF4
        =========================================================
        Name:         Macintosh HD
        Status:       Online
        Size:         119290187776 B (119.3 GB)
        Free Space:   4096 B (4.1 KB)
        |
        +-< Physical Volume AC7A2748-0DA1-49D6-B50C-30348838760E
        |   ----------------------------------------------------
        |   Index:    0
        |   Disk:     disk0s2
        |   Status:   Online
        |   Size:     119290187776 B (119.3 GB)
        |
        +-> Logical Volume Family 4B7E6277-69BC-475A-BBB7-7A94D6434D9E
            Encryption Status:       Unlocked
            Encryption Type:         AES-XTS
            Conversion Status:       Converting
            Conversion Direction:    -none-
            Has Encrypted Extents:   Yes
            Fully Secure:            No
            Passphrase Required:     No
            |
            +-> Logical Volume CC457129-6FE9-41A0-B0D2-F547F21A7555
                Disk:                  disk1
                Status:                Online
                Size (Total):          118954639360 B (119.0 GB)
                Conversion Progress:   -none-
                Revertible:            Yes (unlock and decryption required)
                LV Name:               Macintosh HD
                Volume Name:           Macintosh HD
                Content Hint:          Apple_HFS
    when I type unlock:
    rescomp-14-251133:~ rico$ diskutil corestorage unlockVolume CC457129-6FE9-41A0-B0D2-F547F21A7555 -stdinpassphrase
    CC457129-6FE9-41A0-B0D2-F547F21A7555 is already unlocked and is attached as disk1
    It is already unlocked
    then, I tried revert it
    rescomp-14-251133:~ rico$ diskutil coreStorage revert CC457129-6FE9-41A0-B0D2-F547F21A7555
    Passphrase:
    Started CoreStorage operation on disk1 Macintosh HD
    Error: -69750: Unable to modify a FileVault context
    Does anyone how I can revert it, then merge disk0s2 and disk0s3

    Here is another try via the command line:
    dhcp-10-201-238-248:~ KyleWLawrence$ diskutil coreStorage resizeVolume BB2662B7-58F3-401C-B889-F264D79E68B4 210g
    Started CoreStorage operation
    Checking file system
    Performing live verification
    Checking Journaled HFS Plus volume
    Checking extents overflow file
    Checking catalog file
    Incorrect block count for file 2012.12.11.asl
    (It should be 390 instead of 195)
    Checking multi-linked files
    Checking catalog hierarchy
    Checking extended attributes file
    Checking volume bitmap
    Checking volume information
    Invalid volume free block count
    (It should be 21713521 instead of 21713716)
    The volume MAC OS X was found corrupt and needs to be repaired
    Error: -69845: File system verify or repair failed

  • (view hint or Query  writing method) using views in Select Query

    Need Assistance,
    Hi all,
    My database having many views. while i am joining the views in a select query increase the cost of the querys due to the complex joins in the conditions.
    While checking the select query with views individualy taking less cost.
    Does any hint or query writing method is availabe to avoid the merging of the execution plan of the views?
    I have browsed many related to the mentioned issues,couldn't found any thing that helps me.
    Please help me on this issue,it will be very much helpfull for me.
    Thanks,
    Senthur

    Please read the two threads linked to in the FAQ: {message:id=9360003} and post the relevant details they request, so that people can help you better with your issue.
    We cannot help if you just say "my query is slow what do I do to fix it" as we cannot see your queries, your data, or any other information we would need to help. If the answer was that simple, it would be built into oracle so that the optimiser would fix it for you.

Maybe you are looking for

  • Windows Failed To Start (Windows 7)

    I am not 100% sure where to post this, but I saw a similar post here, but not with the exact problem.  My spouse was playing a video game on the laptop when it suddenly shut down and when he rebooted the computer it gave him the error "Windows Failed

  • Possible to degrade an X5 project to X3 properly??

    I'm a Japanese localize engineer who ususally receives a source (Engilsh) project created in X5 and has to localize it in X3, the latest Japanese version of Robohelp. In these kinds of localizing scenarios, is there any way to degrade the project fro

  • All reflection and no type safety makes Jack a dull boy...

    There has got to be a way of refactoring which takes reflection into account, right? As my project grows larger it's getting crazy trying to remember what needs to be changed when I modify a method name, etc. What are people doing about this? I have

  • PI 2.0 - Interface bulk configuration - Interface Roles

    Hi, I did some research on how to use CLI configuration template do bulk configure Ports depending on their Port description. I found the Interface Role definition located in "Design --> Shared Policy Objects" which seemed perfect to be used inside a

  • MIN, MAX problem pls help????

    I have two columns ID and team_name ID Team_name 7 East Africa 8 Sri Lanka 12 England 5 Pakistan 13 West Indies 11 Australia 14 New Zealand 6 India 9 Canada 10 Zimbabwe I want a query to show me only the 'ID' of the MIN(team_name) so for above data t