CARTESIAN/CROSS JOIN

Hello
I use OBIEE version 11.1.1.6.0. I created made dummy table and column in the physical layer. and join all the dimension table with this fact. but I don't know how the business model to deal with it. can someone help me to create a cross join?
Thank you

Published by: 968086 on October 30, 2012 12:59 AM

Follow this link
http://www.rittmanmead.com/2009/08/Oracle-BI-EE-10-1-3-4-1-reporting-on-non-transactional-dimension-values-equivalence-of-outer-joins/

Score pls help if

Tags: Business Intelligence

Similar Questions

  • Difference between a CROSS JOIN and a Cartesian product of the noted comma?

    Hello everyone,

    Oracle version: Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit
    OS: Linux Fedora Core 17 (x86_64)

    I was practicing on recursive subquery factoring based on oracle examples available in the documentation
    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/statements_10002.htm#i2129904

    I was working on an example that displays the hierarchy of each manager with related employees. Here's how
    WITH tmptab(empId, mgrId, lvl) AS
    (
        SELECT  employee_id, manager_id, 0 lvl
        FROM employees
        WHERE manager_id IS NULL
        UNION ALL
        SELECT  employee_id, manager_id, lvl+1
        FROM employees, tmptab
        WHERE (manager_id = empId)
    )
    SEARCH DEPTH FIRST BY mgrId SET order1
    SELECT LPAD(' ', lvl * 3, ' ') || empId AS empId
    FROM tmptab;
    Which gives the desired result
    EMPID
    ---------------------
    100
       101
          108
          109
          110
          111
          112
          113
          200
          203
          204
          205
          206
       102
          103
          104
          105
          106
          107
       114
          115
          116
          117
          118
          119
       120
          125
          126
          127
          128
          180
          181
          182
          183
       121
          129
          130
          131
          132
          184
          185
          186
          187
       122
          133
          134
          135
          136
          188
          189
          190
          191
       123
          137
          138
          139
          140
          192
          193
          194
          195
       124
          141
          142
          143
          144
          196
          197
          198
          199
       145
          150
          151
          152
          153
          154
          155
       146
          156
          157
          158
          159
          160
          161
       147
          162
          163
          164
          165
          166
          167
       148
          168
          169
          170
          171
          172
          173
       149
          174
          175
          176
          177
          178
          179
       201
          202
    
    107 rows selected.
    
    SQL> 
    However, by chance, I noticed that if I put CROSS JOIN instead of put a comma between table names, the same query behaves differently.

    In other words, if instead of writing
    . . .
    UNION ALL
        SELECT  employee_id, manager_id, lvl+1
        FROM employees, tmptab
        WHERE (manager_id = empId)
    I am writing
    . . .
    UNION ALL
        SELECT  employee_id, manager_id, lvl+1
        FROM employees CROSS JOIN tmptab
        WHERE (manager_id = empId)
    I get the following error message
    ERROR at line 4:
    ORA-32044: cycle detected while executing recursive WITH query
    Any idea?
    Correct me if I'm wrong, but I remember, oracle supports as many JOIN CROSSROADS notation for Cartesian product (vector product =). For example
    SQL> WITH tmptab1 AS
      2  (
      3      SELECT 'a1' AS colval FROM DUAL UNION ALL
      4      SELECT 'a2' AS colval FROM DUAL UNION ALL
      5      SELECT 'a3' AS colval FROM DUAL
      6  ),
      7  tmptab2 AS
      8  (
      9      SELECT 'b1' AS colval FROM DUAL UNION ALL
     10      SELECT 'b2' AS colval FROM DUAL
     11  )
     12  SELECT t1.colval, t2.colval
     13  FROM tmptab1 t1 CROSS JOIN tmptab2 t2;
    
    CO CO
    -- --
    a1 b1
    a2 b1
    a3 b1
    a1 b2
    a2 b2
    a3 b2
    
    6 rows selected.
    
    SQL> LIST 13
     13* FROM tmptab1 t1 CROSS JOIN tmptab2 t2
    SQL>
    SQL>
    SQL> CHANGE /CROSS JOIN/,
     13* FROM tmptab1 t1 , tmptab2 t2
    SQL> 
    SQL>
    SQL> LIST
      1  WITH tmptab1 AS
      2  (
      3  SELECT 'a1' AS colval FROM DUAL UNION ALL
      4  SELECT 'a2' AS colval FROM DUAL UNION ALL
      5  SELECT 'a3' AS colval FROM DUAL
      6  ),
      7  tmptab2 AS
      8  (
      9  SELECT 'b1' AS colval FROM DUAL UNION ALL
     10  SELECT 'b2' AS colval FROM DUAL
     11  )
     12  SELECT t1.colval, t2.colval
     13* FROM tmptab1 t1 , tmptab2 t2
    SQL> 
    SQL> /
    
    CO CO
    -- --
    a1 b1
    a2 b1
    a3 b1
    a1 b2
    a2 b2
    a3 b2
    
    6 rows selected.
    
    SQL> 
    So if the two rated commas and CROSS JOIN have the same semantics, why do I get a cycle mentioned above cites recursive subquery factoring while the same query works pretty well with comma between table instead of CROSS JOIN names? Because if a cycle is detected (= current element ancestor) it means that the product with the CROSS JOIN notation produces duplicates which are absent in the result of the Cartesian product rated comma.

    I would appreciate it if you could kindly shed some light.

    Thanks in advance,

    Kind regards
    Dariyoosh

    Hello

    dariyoosh wrote:
    ... Oracle terminology could become really confusing. But once again, according to the online glossary, a Cartesian product is apparently regarded as a join
    http://docs.Oracle.com/CD/E11882_01/server.112/e25789/glossary.htm?type=popup#CNCPT44493
    >

    There is no doubt that a Cartesian product (also called cross join) is a join. If loops in a WITH recursive clause are detected after completing the joins, but before other conditions apply, the relevant question here is "what are the requirements to join?
    In the ANSI syntax, the distinction is always clear. Join conditions occur in the... Clause WE

    SELECT  employee_id, manager_id, lvl + 1
    FROM      employees
    JOIN        tmptab          ON  (manager_id = empId)     -- Join condition
    ;
    

    and other conditions occur in the WHERE (or HAVING or CONNECT BY) clause.

    SELECT  employee_id, manager_id, lvl + 1
    FROM            employees
    CROSS JOIN         tmptab
    WHERE  (manager_id = empId)     -- NOT a join condition
    ;
    

    In the joins of the former, it seems to be the case that any condition involving 2 or more tables (or the + indicator of outer join) is a condtion of join:

    SELECT  employee_id, manager_id, lvl + 1
    FROM      employees
    ,         tmptab
    WHERE  (manager_id = empId)     -- Join condition
    ;
    
  • Inline query vs cross join

    Hi all

    Two tables which have no relationship with each other. For example, an Employees table and a systemparameter with a startworktime table.

    We need a query with the data in the two tables:

    Get all employees and the startworktime (which is the same for everyone)

    Which is cheaper: an inline query or a product Cartesian or crossjoin?

    Inine:

    Select name, function

    (by selecting startworktime in systemparameter)

    employees;

    Cartesian product:

    SELECT name, function, startwoime

    rktfrom used

    Cross join systemparameter;

    Your opinion about this.

    Both these do the same thing. I seriously doubt if we would have the benefits of performance on the other.

    Kind regards

  • cross join?

    I was asked if the veiw (select what is wrttien to make the view) has a cross join and follwing some ANSI compliance. So my question is... as table 3 below is used by alias tp and same table3 is used by alias tp2... commandeer that be considered as a cross join?

    Sorry, I'm very new to SQL...
    select col1, col2, col3 from table1 t, table2 t1, table3 tp
    where
    ---
    ---
    ---
    AND tp.phs_id =
                          (SELECT tp2.phs_id
                             FROM table3 tp2
                            WHERE tp2.id = tsp.id
                             AND ROWNUM < 2)
    Published by: user11168115 on May 14, 2009 12:43

    Hello (and welcome)
    No, would not be a CROSS JOIN, since your alias tp2 JOINED tp (I guess you mean tp even if you have a TSP). A CROSS JOIN is where no JOIN condition at all is specified for a table (also known as the Cartesian product ), and if it's compatible ANSI SQL will actually be the words CROSS JOIN specified in the JOIN clause. For example:

    SELECT *
       FROM table1
     CROSS JOIN table2;
    

    Otherwise, non-compliant ANSI:

    SELECT *
      FROM table1, table2;
    
  • Auto cross join

    Hello.

    Why Cross join on a table without specifying alias does not work properly ?


    with
        t1 as (
          select 1 as q1, 2 as q2 from dual union 
          select 3, 4 from dual union 
          select 5, 6 from dual
      )
    select *
      from t1
        cross join t1
    order by 1
            Q1         Q2         Q1         Q2
    ---------- ---------- ---------- ----------
             1          2          1          2 
             1          2          1          2 
             1          2          1          2 
             3          4          3          4 
             3          4          3          4 
             3          4          3          4 
             5          6          5          6 
             5          6          5          6 
             5          6          5          6 
    
     9 rows selected 
    

    11.2.0.3.0 - 64 bit

    2837285 wrote:

    Ok.

    Why 10 gr 2 we have error ORA-00918 (same self-join) and 11 g works, but the wrong result?

    Why don't you ask Oracle via a support request, it's a bug.

    You can't say he is working on 11g "but which gives bad result."  Clearly if it is to give a wrong result then it doesn't work.

    What happens on 11g is the fact that it runs without the exception of ambiguous column.  There are a few known bugs in the way SQL ANSI has implemented compared to the regular SQL Oracle syntax.  Oracle worked to correct.

    I don't have 12 c to test, but it may have already been corrected in this version.

  • Extract multiple lines using the technique of the cross join

    Hello.

    Can someone suggest a method to return 3 lines of a query when otherwise would return only one line?

    I am trying to reach the analog SQL logic to this topic-
    SELECT x.foo, p.id, p.name FROM people p CROSS JOIN (SELECT 1 AS foo UNION ALL SELECT 2 UNION ALL SELECT 3) x;
    Reason: I want a result three rows (n) force and use GROUP BY with case statements to create 3 levels summary.

    Here is a simple SQL logical expression that works for my setup - OBI
    SELECT
         "- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number saw_0,
         "- Nx_CSDG0_Repair_Orders (Depot Repair Views)".SR_Operating_Unit_Name saw_1
    FROM
         "[Noetix-NoetixGlobalRepository] NoetixViews for Oracle Service"     
    WHERE 
         ("- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number = '338246')
    But I think that I can't do--
    SELECT
         "- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number saw_0,
         "- Nx_CSDG0_Repair_Orders (Depot Repair Views)".SR_Operating_Unit_Name saw_1
    FROM
         "[Noetix-NoetixGlobalRepository] NoetixViews for Oracle Service"
         CROSS JOIN (SELECT 1 AS foo UNION ALL SELECT 2 UNION ALL SELECT 3)
    WHERE 
         ("- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number = '338246')
    But what peut do?

    Thank you.

    -cs

    Hi CSeelig,

    The BI server uses the ANSI SQL standard. Then all the SQL that follows this specification in OBIEE will work.

    I did an example with intensification:
    http://gerardnico.com/wiki/dat/OBIEE/logical_sql/obiee_sql_densification

    You will see a cross join to make a densification.

    See you soon
    Nico

  • Pivot + cross join

    Hello

    I wrote the following query, which works very well:
    select * from
    (
         select
              to_char(SCB_OPENTIME, 'YYYY-MM') as curr_date,
              SCB_TASK
         from EM_DATA_MSR_SC
    )
    pivot
    (
         count(SCB_TASK) for curr_date in
         (
              '2011-01',
              '2011-02',
              '2011-03',
              '2011-04',
              '2011-05',
              '2011-06',
              '2011-07',
              '2011-08',
              '2011-09',
              '2011-10',
              '2011-11',
              '2011-12'
         )
    );
    Now, I need to apply a cross thereon join:
    select * from
    (
         select
              to_char(SCB_OPENTIME, 'YYYY-MM') as curr_date,
              SCB_TASK
         from EM_DATA_MSR_SC
         where
              EMSCG_STATUS = status.name
    )
    pivot
    (
         count(SCB_TASK) for curr_date in
         (
              '2011-01',
              '2011-02',
              '2011-03',
              '2011-04',
              '2011-05',
              '2011-06',
              '2011-07',
              '2011-08',
              '2011-09',
              '2011-10',
              '2011-11',
              '2011-12'
         )
    )
    cross join
    (
        select 0, 'Closed' as name from DUAL union
        select 1, 'Denied' from DUAL union
        select 2, 'Open' from DUAL
    ) status;
    When I try to run this query, I get this error message:
    "STATUS"."NAME": invalid identifier
    However, SQL is supposed to have brought on a deep level table references.
    I'm doing something wrong?

    Hello

    If this is what you want, then you don't want a cross join. The inner join in the view online with no name is the only reference to beaches you need.

    with ranges as
    (
        select 0, 0 as mini, 20 as maxi from DUAL union
        select 1, 21, 50 from DUAL union
        select 2, 51, 300 from DUAL
    )
    select * from
    (
         select  r.mini,
              r.maxi,
              to_char (t.DAT, 'YYYY-MM')     as curr_date,
              t.NUM
         from      TEST     t
         join      RANGES     r     on      t.NUM >= r.mini
                        and      t.NUM <= r.maxi
    )
    pivot
    (
         count(NUM) for curr_date in
         (
              '2011-01',
              '2011-02',
              '2011-03',
              '2011-04',
              '2011-05',
              '2011-06',
              '2011-07',
              '2011-08',
              '2011-09',
              '2011-10',
              '2011-11',
              '2011-12'
         )
    )
    ORDER BY  mini
    ;
    

    Depending on your data and your needs, you might want an outer join, not an inner join, like this:

    ...     from          RANGES     r
         LEFT OUTER JOIN     TEST     t     on      t.NUM >= r.mini
                             and      t.NUM <= r.maxi
    

    Published by: Frank Kulash, November 7, 2011 12:20
    Alternative ADED of outer join

  • [8i] need help with full outer join combined with a cross join...

    I can't understand how to combine a full outer join with a different type of join... is it possible?

    Here are some create table and insert for examples of database:
    CREATE TABLE     my_tab1
    (     record_id     NUMBER     NOT NULL     
    ,     workstation     VARCHAR2(4)
    ,     my_value     NUMBER
         CONSTRAINT my_tab1_pk PRIMARY KEY (record_id)
    );
    
    INSERT INTO     my_tab1
    VALUES(1,'ABCD',10);
    INSERT INTO     my_tab1
    VALUES(2,'ABCD',15);
    INSERT INTO     my_tab1
    VALUES(3,'ABCD',5);
    INSERT INTO     my_tab1
    VALUES(4,'A123',5);
    INSERT INTO     my_tab1
    VALUES(5,'A123',10);
    INSERT INTO     my_tab1
    VALUES(6,'A123',20);
    INSERT INTO     my_tab1
    VALUES(7,'????',5);
    
    
    CREATE TABLE     my_tab2
    (     workstation     VARCHAR2(4)
    ,     wkstn_name     VARCHAR2(20)
         CONSTRAINT my_tab2_pk PRIMARY KEY (workstation)
    );
    
    INSERT INTO     my_tab2
    VALUES('ABCD','WKSTN 1');
    INSERT INTO     my_tab2
    VALUES('A123','WKSTN 2');
    INSERT INTO     my_tab2
    VALUES('B456','WKSTN 3');
    
    CREATE TABLE     my_tab3
    (     my_nbr1     NUMBER
    ,     my_nbr2     NUMBER
    );
    
    INSERT INTO     my_tab3
    VALUES(1,2);
    INSERT INTO     my_tab3
    VALUES(2,3);
    INSERT INTO     my_tab3
    VALUES(3,4);
    And, the results that I want to get:
    workstation     sum(my_value)     wkstn_name     my_nbr1     my_nbr2
    ---------------------------------------------------------------
    ABCD          30          WKSTN 1          1     2
    ABCD          30          WKSTN 1          2     3
    ABCD          30          WKSTN 1          3     4
    A123          35          WKSTN 2          1     2
    A123          35          WKSTN 2          2     3
    A123          35          WKSTN 2          3     4
    B456          0          WKSTN 3          1     2
    B456          0          WKSTN 3          2     3
    B456          0          WKSTN 3          3     4
    ????          5          NULL          1     2
    ????          5          NULL          2     3
    ????          5          NULL          3     4
    I tried a number of different things, google my problem and no luck yet...
    SELECT     t1.workstation
    ,     SUM(t1.my_value)
    ,     t2.wkstn_name
    ,     t3.my_nbr1
    ,     t3.my_nbr2
    FROM     my_tab1 t1
    ,     my_tab2 t2
    ,     my_tab3 t3
    ...
    So, what I want, it's a full outer join of t1 and t2 on workstation and a cross join of one with the t3. I wonder if I can't find examples of it online because it is not possible...

    Note: I'm stuck dealing with Oracle 8i

    Thank you!!

    Hello

    The query I posted yesterday is a little more complex that it should be.
    My_tab2.workstation is unique, there is no reason to make a separate subquery as mt1. We can join my_tab1 to my_tab2 and get the SUM in a subquery.

    SELECT       foj.workstation
    ,       foj.sum_my_value
    ,       foj.wkstn_name
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    FROM       (     -- Begin in-line view foj for full outer join
              SELECT        mt1.workstation
              ,        SUM (mt1.my_value)     AS sum_my_value
              ,        mt2.wkstn_name
              FROM        my_tab1   mt1
              ,        my_tab2   mt2
              WHERE        mt1.workstation     = mt2.workstation (+)
              GROUP BY   mt1.workstation
              ,        mt2.wkstn_name
                            --
                    UNION ALL
                            --
              SELECT      workstation
              ,      0      AS sum_my_value
              ,      wkstn_name
              FROM      my_tab2
              WHERE      workstation     NOT IN (     -- Begin NOT IN sub-query
                                               SELECT      workstation
                                       FROM      my_tab1
                                       WHERE      workstation     IS NOT NULL
                                     )     -- End NOT IN sub-query
           ) foj     -- End in-line view foj for full outer join
    ,       my_tab3  mt3
    ORDER BY  foj.wkstn_name
    ,       foj.workstation
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    ;
    

    Thanks for posting the CREATE TABLE and INSERT statements, and very clear expected results!

    user11033437 wrote:
    ... So, what I want, it's a full outer join of t1 and t2 on workstation and a cross join of one with the t3.

    She, exactly!
    The trickiest part is when and how get SUM (my_value). You could address the question of exactly what my_tab3 must be attached to a cross that's exactly what should look like the result set of the full outer join between my_tab1 and my_tab2 to. To do this, take your desired results, remove columns that do not come from the outer join complete and delete duplicate rows. You will get:

    workstation     sum(my_value)     wkstn_name
    -----------     -------------   ----------
    ABCD          30          WKSTN 1
    A123          35          WKSTN 2
    B456          0          WKSTN 3
    ????          5          NULL          
    

    So the heart of the problem is how to get these results of my_tab1 and my_tab2, which is done in the subquery FOJ above.

    I tried to use auto-documenté in my code names. I hope you can understand.
    I could spend hours explaining the different parts of this query more in detail, but I don't know that I would lose some of that time, explain things that you already understand. If you want an explanation of the specific element (s), let me know.

  • the group causing a Cartesian merge join?

    Hi all
    Database Version: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    Database Version: PL/SQL Release 10.2.0.5.0 - Production
    I wrote a query that runs in less than a second and produced a few hundred lines (as you can see below). I wanted only to find the number of separate incidents ID returned so I put a group by at the end and it ran forever.

    I realized a plan to explain (as shown below) to the query with the group inside and he tries to make a Cartesian join!

    A WTF happening? I've never known a group by statement before.

    basic structure of the tables is the following:
    SQL> desc answer_master
     Name                                                                     Null?    Type
     ------------------------------------------------------------------------ -------- -----------------
     ANSWER_ID                                                                NOT NULL NUMBER(12)
     INCIDENT_ID                                                              NOT NULL NUMBER(12)
     PLAN_ID                                                                  NOT NULL NUMBER(12)
     QUESTION_ID                                                              NOT NULL NUMBER(12)
    
    SQL> desc question_master
     Name                                                                     Null?    Type
     ------------------------------------------------------------------------ -------- -----------------
     QUESTION_PLAN_ID                                                         NOT NULL NUMBER(12)
     QUESTION_ID                                                              NOT NULL NUMBER(12)
     QUESTION_TYPE                                                            NOT NULL NUMBER(2)
     QUESTION_TEXT                                                            NOT NULL VARCHAR2(255)
     QUESTION_PARENT_ID                                                                NUMBER(12)
    the SQL statement
    SQL> explain plan for
      2  select incident_id
      3    from answer_master am
      4   where exists (select 'x'
      5                   from answer_master am1
      6                  where question_id in (select question_id
      7                               from question_master qms
      8                              where question_plan_id = 1477
      9                                and question_parent_id = 69067
     10                                and substr(question_text,-3) = 'PDF')
     11                    and am1.incident_id = am.incident_id)
     12    and exists (select 'x'
     13                   from answer_master am1
     14                  where question_id in (select question_id
     15                               from question_master qms
     16                              where question_plan_id = 1477
     17                                and question_parent_id = 69067
     18                                and substr(question_text,-3) != 'PDF')
     19                    and am1.incident_id = am.incident_id);
    
    Explained.
    
    Elapsed: 00:00:00.01
    SQL> set linesize 132;
    SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
    
    PLAN_TABLE_OUTPUT                                                                                                                   
    ------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 1710257923                                                                                                         
                                                                                                                                        
    ----------------------------------------------------------------------------------------------------------                          
    | Id  | Operation                        | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |                          
    ----------------------------------------------------------------------------------------------------------                          
    |   0 | SELECT STATEMENT                 |                       |     1 |    32 |   171   (6)| 00:00:01 |                          
    |*  1 |  HASH JOIN RIGHT SEMI            |                       |     1 |    32 |   171   (6)| 00:00:01 |                          
    |   2 |   VIEW                           | VW_SQ_2               |    71 |   923 |    70   (5)| 00:00:01 |                          
    |   3 |    NESTED LOOPS                  |                       |    71 |  3266 |    70   (5)| 00:00:01 |                          
    |*  4 |     TABLE ACCESS BY INDEX ROWID  | QUESTION_MASTER       |     1 |    35 |     2   (0)| 00:00:01 |                          
    |*  5 |      INDEX RANGE SCAN            | QUESTION_MASTER_IX1   |     3 |       |     1   (0)| 00:00:01 |                          
    |*  6 |     INDEX RANGE SCAN             | ANSWER_MASTER_QID_IX2 | 18731 |   201K|    68   (5)| 00:00:01 |                          
    |   7 |   NESTED LOOPS                   |                       |   304 |  5776 |   100   (5)| 00:00:01 |                          
    |   8 |    VIEW                          | VW_SQ_1               |    14 |   182 |    70   (5)| 00:00:01 |                          
    |   9 |     HASH UNIQUE                  |                       |    14 |   644 |            |          |                          
    |  10 |      NESTED LOOPS                |                       |    14 |   644 |    70   (5)| 00:00:01 |                          
    |* 11 |       TABLE ACCESS BY INDEX ROWID| QUESTION_MASTER       |     1 |    35 |     2   (0)| 00:00:01 |                          
    |* 12 |        INDEX RANGE SCAN          | QUESTION_MASTER_IX1   |     3 |       |     1   (0)| 00:00:01 |                          
    |* 13 |       INDEX RANGE SCAN           | ANSWER_MASTER_QID_IX2 | 18731 |   201K|    68   (5)| 00:00:01 |                          
    |* 14 |    INDEX RANGE SCAN              | ANSWER_MASTER_QID_IX3 |    22 |   132 |     2   (0)| 00:00:01 |                          
    ----------------------------------------------------------------------------------------------------------                          
                                                                                                                                        
    Predicate Information (identified by operation id):                                                                                 
    ---------------------------------------------------                                                                                 
                                                                                                                                        
       1 - access("ITEM_2"="AM"."INCIDENT_ID")                                                                                          
       4 - filter("QUESTION_PLAN_ID"=1477 AND SUBSTR("QUESTION_TEXT",-3)!='PDF')                                                        
       5 - access("QUESTION_PARENT_ID"=69067)                                                                                           
       6 - access("QUESTION_ID"="QUESTION_ID")                                                                                          
      11 - filter("QUESTION_PLAN_ID"=1477 AND SUBSTR("QUESTION_TEXT",-3)='PDF')                                                         
      12 - access("QUESTION_PARENT_ID"=69067)                                                                                           
      13 - access("QUESTION_ID"="QUESTION_ID")                                                                                          
      14 - access("ITEM_1"="AM"."INCIDENT_ID")                                                                                          
    
    33 rows selected.
    
    Elapsed: 00:00:00.06
    SQL> explain plan for
      2  select incident_id
      3    from answer_master am
      4   where exists (select 'x'
      5                   from answer_master am1
      6                  where question_id in (select question_id
      7                               from question_master qms
      8                              where question_plan_id = 1477
      9                                and question_parent_id = 69067
     10                                and substr(question_text,-3) = 'PDF')
     11                    and am1.incident_id = am.incident_id)
     12    and exists (select 'x'
     13                   from answer_master am1
     14                  where question_id in (select question_id
     15                               from question_master qms
     16                              where question_plan_id = 1477
     17                                and question_parent_id = 69067
     18                                and substr(question_text,-3) != 'PDF')
     19                    and am1.incident_id = am.incident_id)
     20  group by incident_id;
    
    Explained.
    
    Elapsed: 00:00:00.00
    SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
    
    PLAN_TABLE_OUTPUT                                                                                                                   
    ------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 1433543102                                                                                                         
                                                                                                                                        
    -----------------------------------------------------------------------------------------------------------                         
    | Id  | Operation                         | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |                         
    -----------------------------------------------------------------------------------------------------------                         
    |   0 | SELECT STATEMENT                  |                       |     1 |    98 |    77   (6)| 00:00:01 |                         
    |   1 |  HASH GROUP BY                    |                       |     1 |    98 |    77   (6)| 00:00:01 |                         
    |   2 |   NESTED LOOPS                    |                       |     1 |    98 |    76   (4)| 00:00:01 |                         
    |   3 |    NESTED LOOPS                   |                       |     1 |    87 |    74   (5)| 00:00:01 |                         
    |   4 |     NESTED LOOPS                  |                       |     1 |    81 |    72   (5)| 00:00:01 |                         
    |   5 |      MERGE JOIN CARTESIAN         |                       |     1 |    70 |     4   (0)| 00:00:01 |                         
    |*  6 |       TABLE ACCESS BY INDEX ROWID | QUESTION_MASTER       |     1 |    35 |     2   (0)| 00:00:01 |                         
    |*  7 |        INDEX RANGE SCAN           | QUESTION_MASTER_IX1   |     3 |       |     1   (0)| 00:00:01 |                         
    |   8 |       BUFFER SORT                 |                       |     1 |    35 |     2   (0)| 00:00:01 |                         
    |*  9 |        TABLE ACCESS BY INDEX ROWID| QUESTION_MASTER       |     1 |    35 |     2   (0)| 00:00:01 |                         
    |* 10 |         INDEX RANGE SCAN          | QUESTION_MASTER_IX1   |     3 |       |     1   (0)| 00:00:01 |                         
    |* 11 |      INDEX RANGE SCAN             | ANSWER_MASTER_QID_IX2 | 18731 |   201K|    68   (5)| 00:00:01 |                         
    |* 12 |     INDEX RANGE SCAN              | ANSWER_MASTER_QID_IX3 |    22 |   132 |     2   (0)| 00:00:01 |                         
    |* 13 |    INDEX RANGE SCAN               | ANSWER_MASTER_QID_IX2 |     1 |    11 |     2   (0)| 00:00:01 |                         
    -----------------------------------------------------------------------------------------------------------                         
                                                                                                                                        
    Predicate Information (identified by operation id):                                                                                 
    ---------------------------------------------------                                                                                 
                                                                                                                                        
       6 - filter("QUESTION_PLAN_ID"=1477 AND SUBSTR("QUESTION_TEXT",-3)='PDF')                                                         
       7 - access("QUESTION_PARENT_ID"=69067)                                                                                           
       9 - filter("QUESTION_PLAN_ID"=1477 AND SUBSTR("QUESTION_TEXT",-3)!='PDF')                                                        
      10 - access("QUESTION_PARENT_ID"=69067)                                                                                           
      11 - access("QUESTION_ID"="QUESTION_ID")                                                                                          
      12 - access("AM1"."INCIDENT_ID"="AM"."INCIDENT_ID")                                                                               
      13 - access("QUESTION_ID"="QUESTION_ID" AND "AM1"."INCIDENT_ID"="AM"."INCIDENT_ID")                                               
    
    31 rows selected.
    
    Elapsed: 00:00:00.00
    SQL> spool off
    Edit: change superiors--more/less to signs of! = to display the Forum

    Published by: WhiteHat on February 11, 2011 09:37

    In addition, if you are interested in rewriting so I think this might be an alternative (untested):

          select am1.incident_id
          from   answer_master am1
          ,      question_master qms
          where  am1.question_id        = qms.question_id
          and    qms.question_plan_id   = 1477
          and    qms.question_parent_id = 69067
          group by am1.incident_id
          having max(case when substr(qms.question_text,-3) = 'PDF' then 1 else 0 end) !=
                 min(case when substr(qms.question_text,-3) = 'PDF' then 1 else 0 end);
    
  • Cross join to Hi in oracle

    Hello

    I have below the text values.

    Platimum

    Silver

    VIP

    Bronze

    I want to get cross-from above like four

    PlatimumSilverVIPBronze
    PlatimumVIPSilverBronze
    PlatimumBronzeVIPSilver
    PlatimumSilverVIPBronze

    And so on. It should give me 16 combinations that I guess.

    How can I achieve this?

    Kind regards

    Mahesh

    Another way to generate permutations (if nocycle seems suspicious)

    with

    data in the form of

    (select "Platimum" val of union double all the)

    Select 'Cash' of all the double union

    Select 'VIP' of all the double union

    Select "Bronze" double

    ),

    permutator (swap) as

    (select val

    from the data

    Union of all the

    Select swap. «, » || Val

    data,.

    permutator

    where instr (permutation, val) = 0

    )

    Select the permutation

    of the permutator

    where regexp_count (permutation, ',') = 3

    order by swapping

    PERMUTATION
    Bronze, Platimum, silver, VIP
    Bronze, Platimum, VIP, Silver
    Bronze, Silver, Platimum, VIP
    Bronze, Silver, VIP, Platimum
    Bronze, VIP, Platimum, Silver
    Bronze, Silver, VIP, Platimum
    Platimum, Bronze, silver, VIP
    Platimum, Bronze, Silver, VIP
    Platimum, silver, Bronze, VIP
    Platimum, silver, VIP, Bronze
    Platimum, VIP, Bronze, silver
    Platimum, VIP, silver, Bronze
    Silver, Bronze, Platimum, VIP
    Silver, Bronze, VIP, Platimum
    Money, Platimum, Bronze, VIP
    Silver, Platimum, VIP, Bronze
    Silver, VIP, Bronze, Platimum
    Silver, VIP, Platimum, Bronze
    VIP, Bronze, Platimum, silver
    VIP Bronze, silver, Platimum
    VIP, Platimum, Bronze, silver
    VIP, Platimum, silver, Bronze
    VIP, silver, Bronze, Platimum
    VIP, money, Platimum, Bronze
  • MERGE JOIN Cartesian help

    Hi all

    I have a problem in writing the query below. The following query always shows a MERGE JOIN CARTESIAN in the plan to explain due to which the execution of the query takes a long time (almost 2 hours for 1,000 records).

    I use "Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi. Please advice if I need to provide more information on that.
    Select to_char(a.amnt_date,'DD-MON-YYYY') amnt_date, 
           SUM(a.AMNT_CON) amount
    from amount a, 
         (SELECT area_no  
             FROM (SELECT * 
                      FROM area_usage 
                      WHERE area_hier_no = '201064') 
          CONNECT BY area_par_no = PRIOR area_no 
          START WITH area_no in (SELECT area_no 
                                    FROM area 
                                    WHERE area_code in ('EQ'))) b,
         (SELECT acc_no
             FROM (SELECT * 
                     FROM acc_usage 
                    WHERE acc_hier_no = '1') 
          CONNECT BY acc_par_no = PRIOR acc_no 
          START WITH acc_no = 202917) c --  Account Hierarchy
    where a.area_no = b.area_no 
       AND a.acc_no = c.acc_no
    GROUP BY a.amnt_date
    -----

    PLAN_TABLE_OUTPUT

    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Hash value of plan: 2492729134

    -----------------------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |
    -----------------------------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 692. 22144 | 3327 (32) | 00:00:40 |
    | 1. HASH GROUP BY. 692. 22144 | 3327 (32) | 00:00:40 |
    | 2. TABLE ACCESS BY LOCAL INDEX ROWID | AMOUNT | 138. 2898. 3326 (32) | 00:00:40 |
    | 5: NESTED LOOPS | 692. 22144 | 3326 (32) | 00:00:40 |
    | 4. THE CARTESIAN MERGE JOIN. 5. 55. 13 (0) | 00:00:01 |
    | 5. VIEW | 1. 5. 5 (0) | 00:00:01 |
    |* 6 | CONNECT BY WITH FILTERING |
    | 7. TABLE ACCESS BY INDEX ROWID | ACC_USAGE | 1. 24. 2 (0) | 00:00:01 |
    |* 8 | INDEX UNIQUE SCAN | ACU_PK | 1 | | 1 (0) | 00:00:01 |
    | 9. NESTED LOOPS |
    | 10. CONNECT PUMP |
    | * 11 | TABLE ACCESS BY INDEX ROWID | ACC_USAGE | 1. 14. 5 (0) | 00:00:01 |
    | * 12 | INDEX RANGE SCAN | ACU_AH_HAVE_AS_PARENT_FK_I | 4 | | 1 (0) | 00:00:01 |
    | 13. KIND OF BUFFER. 5. 30. 13 (0) | 00:00:01 |
    | 14. VIEW | 5. 30. 8 (0) | 00:00:01 |
    | * 15 | CONNECT BY WITH FILTERING |
    | * 16. TABLE ACCESS BY INDEX ROWID | AREA_USAGE |
    | 17. NESTED LOOPS | 1. 32. 2 (0) | 00:00:01 |
    | 18. TABLE ACCESS BY INDEX ROWID | AREA | 1. 21. 2 (0) | 00:00:01 |
    | * 19. INDEX UNIQUE SCAN | AR_AR2_UK | 1 | | 1 (0) | 00:00:01 |
    | * 20. INDEX UNIQUE SCAN | AU_PK | 8608. 94688 | 0 (0) | 00:00:01 |
    | 21. NESTED LOOPS |
    | 22. CONNECT PUMP |
    | * 23. TABLE ACCESS BY INDEX ROWID | AREA_USAGE | 5. 85. 8 (0) | 00:00:01 |
    | * 24. INDEX RANGE SCAN | ARU_APN_FKI | 8 | | 1 (0) | 00:00:01 |
    | 25. RANGE OF PARTITION ALL THE | 1. 60.
    | 26. CONVERSION OF BITMAP IN ROWID |
    | 27. BITMAP AND |
    | 28. CONVERSION OF BITMAP OF ROWID |
    | * 29. INDEX RANGE SCAN | A_ARH_FK_I | 194K | 134 (7) | 00:00:02 | 1. 60.
    | 30. CONVERSION OF BITMAP OF ROWID |
    | * 31. INDEX RANGE SCAN | A_AH_FK_I | 194K | 488 (41) | 00:00:06 | 1. 60.
    -----------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    6 - access("ACC_USAGE".") ACC_PAR_NO "="ACC_USAGE"ADVANCE." ACC_NO")
    8 - access("ACC_USAGE".") ACC_NO "= 202917 AND ACC_HIER_NO" = 1) «»
    11 - filter ("ACC_HIER_NO" = 1)
    12 - access("ACC_USAGE".") ACC_PAR_NO "="ACC_USAGE"ADVANCE." ACC_NO")
    15 - access("AREA_USAGE".") AREA_PAR_NO "="AREA_USAGE"ADVANCE." AREA_NO')
    16 - filter ("AREA_HIER_NO" = 201064)
    19 - access ("AREA_CODE" = 'EQ')
    20 - access ("AREA_HIER_NO"= "AREA_USAGE" AND 201064." AREA_NO "=" AREA_NO")
    23 - filter ("AREA_HIER_NO" = 201064)
    24 - access("AREA_USAGE".") AREA_PAR_NO "="AREA_USAGE"ADVANCE." AREA_NO')
    29 - access("A".") AREA_NO '=' B '. ("' AREA_NO")
    31 - access("A".") ACC_NO '=' C '. ("' ACC_NO")

    54 selected lines.

    Published by: Williams James Henderson on October 14, 2010 05:31

    It is a very small difference, and I don't expect to cause huge changes in an execution plan. Either way to collect statistics, you would use the DBMS_STATS package.

    Furthermore, your "formatted" execution plan is not exactly readable in your message.

    Looking at your request a little more closely, I recommend you remove the SELECT * from subqueries. Something like that may be sufficient:

    Select to_char(a.amnt_date,'DD-MON-YYYY') amnt_date,
           SUM(a.AMNT_CON) amount
    from amount a,
         (SELECT area_no
             FROM (SELECT area_no
                        , area_par_no
                      FROM area_usage
                      WHERE area_hier_no = '201064')
          CONNECT BY area_par_no = PRIOR area_no
          START WITH area_no in (SELECT area_no
                                    FROM area
                                    WHERE area_code in ('EQ'))) b,
         (SELECT acc_no
             FROM (SELECT acc_no
                        , acc_par_no
                     FROM acc_usage
                    WHERE acc_hier_no = '1')
          CONNECT BY acc_par_no = PRIOR acc_no
          START WITH acc_no = 202917) c --  Account Hierarchy
    where a.area_no = b.area_no
       AND a.acc_no = c.acc_no
    GROUP BY a.amnt_date
    

    A SELECT statement using * and not at a later time using all the columns hides valuable information from Oracle. If you provide only the columns used Oracle may be able to find a better plan of execution.

    Given that I don't know the structures of table if you can actually use all the columns. I still recommend the amendment because I think that it makes the code easier to understand.

  • is "join Cartesian" identical "merge join Cartesian"?

    Hi guys,.

    my plan to explain said the Cartesian merge join
    [Oracle documentation | http://download-west.oracle.com/docs/cd/B10500_01/server.920/a96533/optimops.htm#45485] speaks of Cartesian join

    Are these two the same?

    Thank you

    Hello

    Both are the same but the NAP differs from 9i to 10g, since according to the algorithm basedon Version in! 0 g's
    Kind of buffer.

    Look at the example of wirh links.

    http://www.juliandyke.com/optimisation/operations/MergeJoinCartesian.html
    http://www.akadia.com/services/ora_interpreting_explain_plan.html

    -Pavan Kumar N

  • Expected to a join behaviours?

    Hello

    formalities:

    Select * from version of v$.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for 64-bit Windows: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    the question:

    I was just wondering why this "join" between A and B do not work. A has no lines, B a 1 row

    > my first answer... it should give 1 rank...

    but alas... it doesn't!

    the original request:

    SELECT A.*,
      B.*,
    CASE WHEN A.METH = 'PAL' THEN '1'
      ELSE A.CFGNR_OFRESTPAL 
    END VWNR_OFRESTPAL
    FROM    CDCROBOTVERDICHTLOCSTATVW A,
      CDCVERDICHTSETTINGSVW B
    

    > No rows returned

    so I checked the counts:

    Select count (*) in the CDCROBOTVERDICHTLOCSTATVW A;

    0

    Select count (*) in the CDCVERDICHTSETTINGSVW B;

    1

    Hmmm... very strange

    so I ran a few tests more:

    SELECT  A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL
    FROM    CDCVERDICHTSETTINGSVW B , CDCROBOTVERDICHTLOCSTATVW A 
    

    > no line

    SELECT A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL
    FROM    CDCVERDICHTSETTINGSVW B cross join CDCROBOTVERDICHTLOCSTATVW A 
    

    > no line

    SELECT A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL
    FROM    CDCVERDICHTSETTINGSVW B full outer join CDCROBOTVERDICHTLOCSTATVW A on 1 =1
    

    > This returns the line from B correctly

    ARTNR PROJECTNR VARIANT PROVIDER QMAX PRIO METH PALLETS SOMQTY FULLPALS RESTQTY RESTPALS CFGNR_OFRESTPAL FREELOCS DUMMYRECIP GEEN_VERDICHTING MAXSRCPALS MAXOPENPICKSETS NR_OF_RESTPAL ORDTYPE PRIO_ARTNR VERD_INRGRP VWNR_OFRESTPAL
    VERDICHT1143VERDICHTQSE00918CLL80CDCROB

    SELECT A.*, B.*, CASE WHEN A.METH = 'PAL' THEN '1' ELSE A.CFGNR_OFRESTPAL END VWNR_OFRESTPAL
    FROM  CDCVERDICHTSETTINGSVW B left join CDCROBOTVERDICHTLOCSTATVW A on 1 = 1
    

    > it is also returns the same rank B

    Does anyone have an idea on how to fix this... or where to look to fix this?

    This is a cross join. It is a Cartesian product. If there are no rows in a table, then you get no rows in the result.

    SQL> with a as (select 1 x from dual), b as (select 1 y from dual where 1=0)
      2  select a.*, b.*
      3  from a, b;                                                             
    
    no rows selected
    

    A left or right, or full outer join is apparently what you wanted.

  • Join the error in mapping!

    Hello

    I have 4 source tables and table a target. While the mapping of the source to the target table, I get following error:


    Review: Default data set     All stores data in a dataset must be attached. This data set has several sets of storage of data source disconnected. The sets are: [src1, src2, src3, src4]. To design a Cartesian product, create a join and select join cross in its properties.     

    Because of this error flow chart cannot be created and showing the error message.

    Can someone tell me what exactly I have to do to make this work?

    Thank you
    Shri

    If you need a Cartesian join between the tables, you must put a cross join. ODI is in need of a join (normal join or cross join) between all of the tables that you put in an interface.

  • Hint ordered and produced Cartesian

    I have a question that needs to be tuned.

    The initial request does not cross in plan product, when I change the order of the tables in the from clause (I placed the # fewer lines first and the more lines tables in the last) and I get product CARTESIAN MERGE JOIN where clause remaining the same, and the cost increases 7180 to 454 m.

    This happens with ordered hint.

    ranjus wrote:
    I have a question that needs to be tuned.

    The initial request does not cross in plan product, when I change the order of the tables in the from clause (I placed the # fewer lines first and the more lines tables in the last) and I get product CARTESIAN MERGE JOIN where clause remaining the same, and the cost increases 7180 to 454 m.

    This happens with ordered hint.

    Let's take a look at this with a simple test case. Suppose that:
    * Table T1 contains 10,000 rows
    * Table T2 contains 100 lines
    * Table T3 contains 100,000 rows
    * Table T4 contains 10 lines

    You have the following query:

    SELECT
      T1.C1,
      T2.C2,
      T3.C3,
      T4.C4
    FROM
      T1,
      T2,
      T3,
      T4
    WHERE
      T1.C1=T2.C2
      AND T2.C2=T3.C2
      AND T3.C3=T4.C3;
    

    In the above, you can see that in the WHERE clause:
    * Table T1 is attached to table T2
    * The T2 table is attached to the tables T1 and T3
    * Table T3 is attached to the T2 and T4 tables
    * Table T4 joined table T3

    It seems you are trying to do, it's something like this based on the number of rows in the tables:

    SELECT /*+ ORDERED */
      T1.C1,
      T2.C2,
      T3.C3,
      T4.C4
    FROM
      T4,
      T2,
      T1,
      T3
    WHERE
      T1.C1=T2.C2
      AND T2.C2=T3.C2
      AND T3.C3=T4.C3;
    

    In the light of the foregoing, we force optimizer Oracle to join the tables T4 and T2 - but there is no direct relationship between the two tables described in the WHERE clause. In one such case, Oracle optimizer must perform a Cartesian join between T4 and T2 tables. Then the T1 table has a relationship defined in the WHERE clause with the table T2, so that the join would not result in a Cartesian product. Finally, the T3 array has a relationship between tables T2 and T4, so that would not result in a Cartesian product.

    Back to this example, suppose table T4 contained a single line. The execution plan still shows a Cartesian join, but this Cartesian join is no worse than a join of nested loops because there is only one line in one of the sources of the line.

    In short, think what you try to force the optimizer to do. You cannot join always ascending rank cardinality estimates - it simply is not logic to try in some cases.

    Charles Hooper
    Co-author of "Expert Oracle practices: Oracle Database Administration of the Oak Table.
    http://hoopercharles.WordPress.com/
    IT Manager/Oracle DBA
    K & M-making Machine, Inc.

Maybe you are looking for

  • No Service iPhone trouble 7

    Has anyone tried this before? "My not to perform the"fix" . on the phone, turn off the LTE voice. leave as data only turn off wifi calling under the settings menu of the phone (probably is not serious but do it anyway) Sign in to your My Verizon acco

  • Window drop down bookmarks on the menu bar is missing

    My Favorites are not missing, because I can access it through the sidebar. However, I prefer the drop-down list in the Menu bar for my favorites. It is easier for me. The Favorites drop-down list box has disappeared and I can't determine how to resto

  • Satellite L840: Win 8.1 installed as 1 BONE but does not start correctly

    I have a problem with my new L840 Satellite Next steps on installing Windows 8, 1 and in the process, he said on-screen that download to update and restart just stays on the screen with circles of loading windows... How can I go to the BIOS? Tried F2

  • Waveshaping circuit using a 555 timer

    I tried to reproduce this circuit much longer. I am trying to use a timer 555 as an Astable multivibrator with a suddenly IC monostable circuit.  However, when I create the circuit and use different combinations of RC I actually get a correct output

  • Hénon map

    Hi all I am creating a Henon map illustration on labview but I got some errors. the vi is attached. I hope someone help Thank you