Right order of joining tables

Hi everybody,
I have read the SQL Tuning section of Performance Tuning Oracle Book of Oracle 10g. v.2.
In 11.5.4. paragraph titled "Controlling the Access Path and Join Order with Hints" , in the second note there is a small paragraph about the right join of the tables....
In whichever query i try ,i've noticed that altering the joining order of the tables the sql statistics (consistent gets , sorts(memory/disk)) are the same regardless of the join order....
Can you please give me an example or a source in which the modification of the join order of the tables in a sql query produce different results ...in statistics????
Thanks , a lot
Simon

Duplicate post. Don't answer this thread please Right order of joining tables.
Cheers, APC

Similar Messages

  • The order of joining the tables in a query ANSI92

    Hi all!
    I have three table in Univerce.
    I need that those tables joined in next order:
    tab1 inner join tab2 right join tab3
    When creating a report in WebI they are connected as (regardless of the order of dimentions):
    tab1 right join tab3 inner join tab2
    How to set the correct order of joining the tables?
    OR
    how to change RIGHT OUTER JOIN on LEFT OUTER JOIN ?
    P.S. I use BO XI3.1, which not have parameter OUTERJOINS_GENERATION
    Thanks!

    it depends on your source system
    for example if you are using oracle, you can edit the link between the table and add this
    (+)
    for example
    TAB1.ID = TAB2.ID (+)
    AND TAB1.DEPT  = TAB2.DEPT(+)
    See the following link for discussing outer and inner joins for oracle
    http://www.dba-oracle.com/t_outer_joins.htm
    good luck
    Amr

  • Table order in join, how?

    obiee generate sql like this
    select ... from ( select ... from T1, T2) d1 left outer join (select ... from T1, T3 ) d2 on d1.c1 = d2.c1
    in this case I need right outer join (becouse first select have less rows then second)
    or change like this
    select ... from ( select ... from T1, T3) d2 left outer join (select ... from T1, T2 ) d1 on d1.c1 = d2.c1
    is it possible?
    maybe in BMM or where else?

    elunin!,
    as per your subject line - "table order in join", I think specifying the driving table option looks pertinent. Thus in the bmm layer you have the option driving table, which might help.
    J
    -bifacts
    http://www.obinotes.com

  • Procedure fails to compile, because of "Order By" on join table

    I am trying to convert a working script into a procedure. The script works fine, but when placed in a procedure, I get the following error:
    [Error] Syntax check (4: 71): ERROR line 4, col 71, ending_line 4, ending_col 75, Found 'order', an alias is not allowed here (reserved for XMLCOLATTVAL, XMLFOREST and XMLATTRIBUTES only)
    I am essentially trying to make sure that the values are ordered chronologically when placed into the string. Any ideas on why this fails as a procedure or how to ensure the chronological ordering?
    I have also noticed that this error does not occur if I am only querying one table (no join, no order by other table field).
    The Order By columns are unique to the second table. Aliasing doesn't help.
    Jason
    CREATE OR REPLACE PROCEDURE AHSANALYTICS.delme_jjs IS
    tmpVar varchar2(3000);
    BEGIN
            SELECT collect_to_string(CAST(COLLECT(TO_CHAR(cs_description) order by CL_DATE_REQUESTED desc) AS collect_table),' >> ') AS cs_description_collect
            into tmpvar
            FROM   f_consul_link            f_consul_link,
                   f_consultations          f_consultations
            WHERE  f_consul_link.cl_pp_sequ      = 2973968 AND
                   f_consul_link.cl_cs_sequ      = f_consultations.cs_sequ (+)
            GROUP BY cl_pp_sequ;
            dbms_output.put_line('tmpvar = '||tmpvar);
    END delme_jjs;
    /But the same code (minus the INTO) works fine as a script
    SELECT collect_to_string(CAST(COLLECT(TO_CHAR(cs_description) order by CL_DATE_REQUESTED ASC, CL_SEQU ASC) AS collect_table),' >> ') AS cs_description_collect
    FROM   f_consul_link            f_consul_link,
           f_consultations          f_consultations
    WHERE  f_consul_link.cl_pp_sequ      = 2973968 AND
           f_consul_link.cl_cs_sequ      = f_consultations.cs_sequ (+)
    GROUP BY cl_pp_sequ
    ;The "collect_to_string" function is this:
    CREATE OR REPLACE FUNCTION AHSANALYTICS.collect_to_string (
        nt_in IN collect_table,
        delimiter_in IN VARCHAR2 DEFAULT ','
    This function helps to concatenate a set of strings into a single field.
    Author         :  http://oracle101.blogspot.com/2008/08/oracle-collect-function.html
    Parameters     : collect_table and delimiter_in
    Created Date   : 2011-Jan-10
    Example Script :   CREATE OR REPLACE TYPE collect_table AS TABLE OF VARCHAR2 (4000);
                        SELECT
                          MAX(pp_sequ)
                        , MAX(RC.CONS_SEQ) AS ED_CONSULTS
                        , collect_to_string(CAST(COLLECT(RC.CONSULT_GROUP) AS collect_table),' >> ') AS temp123
                        , MIN(RC.CONSULT_REQUESTED_DT) AS ED_FIRST_CONSULT_DT
                        FROM HSA_TGT.redis_consults rc
                        WHERE
                          PP_SEQU = 1183707
                        GROUP BY pp_sequ;
    Change History :
        yyyy-mmm-dd    Author   Description
        2011-Jan-10    JJS      Creation of script
        RETURN VARCHAR2
    IS
        v_idx PLS_INTEGER;
        v_str VARCHAR2 (32767);
        v_dlm VARCHAR2 (10);
    BEGIN
        v_idx := nt_in.FIRST;
        WHILE v_idx IS NOT NULL
        LOOP
            v_str := v_str || v_dlm || nt_in (v_idx);
            v_dlm := delimiter_in;
            v_idx := nt_in.NEXT (v_idx);
        END LOOP;
        RETURN v_str;
    END collect_to_string;
    /

    Jason_S wrote:
    David,
    The issue only seems to arise when there are two tables joined, and the order by is based on the 'other' table.
    JasonNot here....
    SQL> create table another_table
      2  (   id number
      3  )
      4  /
    SQL> declare
      2
      3      tmpvar      varchar2(100);
      4
      5  BEGIN
      6          SELECT collect_to_string
      7                  (   CAST
      8                      (   COLLECT
      9                          (   TO_CHAR(cs_description)
    10                              order by id desc
    11                          ) AS collect_table
    12                      ),
    13                      ' >> '
    14                  ) AS cs_description_collect
    15          into tmpvar
    16          FROM   f_consul_link            f_consul_link,
    17                  another_table
    18          WHERE  f_consul_link.cl_pp_sequ      = 2973968
    19          AND
    20                  f_consul_link.cl_pp_sequ = another_table.id (+)
    21          GROUP BY cl_pp_sequ;
    22  END ;
    23  /
    PL/SQL procedure successfully completed.
    SQL> declare
      2
      3      tmpvar      varchar2(100);
      4
      5  BEGIN
      6          SELECT collect_to_string
      7                  (   CAST
      8                      (   COLLECT
      9                          (   TO_CHAR(cs_description)
    10                              order by id desc
    11                          ) AS collect_table
    12                      ),
    13                      ' >> '
    14                  ) AS cs_description_collect
    15          into tmpvar
    16          FROM   f_consul_link            f_consul_link,
    17                  another_table
    18          WHERE  f_consul_link.cl_pp_sequ      = 2973968
    19          AND
    20                  f_consul_link.cl_pp_sequ = another_table.id
    21          GROUP BY cl_pp_sequ;
    22  END ;
    23  /
    declare
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 6Again, maybe you could post your create table statements and full version of oracle....although it is fairly academic given the alternative ways to aggregate strings in the links provided.
    David

  • Import table data in right order to avoid violating foreign key constraints

    Gentlemen
    I am trying to import table data into an existing 10g schema using datapump import in table mode.
    However, in order to avoid violating foreign key constraints, the tables must be loaded in a specified order. I tried specifying the order in the TABLES parameter:
    TABLES=table1,table2,table3 etc.
    However, datapump seems to chose its own order leading to errors like the following:
    ORA-31693: Table data object "SCHEMAX"."TABLE3" failed to load/unload and is being skipped due to error:
    ORA-02291: integrity constraint (SCHEMAX.TABLE3_TABLE1#FK) violated - parent key not found
    I want to try to avoid having to disable all foreign keys because there are hundreds of them.
    Any advice?
    Yours
    Claus Jacobsen, Denmark

    Thanks Anantha.
    Since I am only loadding data (the constraints are already defined in the target database), I am not sure whether this approach would work. Meanwhile I have solved the problem of moving data from one system to another using another, tedious and far from elegant approach that I would prefer to not eloborate on:-)
    However, I have also discovered another probable reason why the foreign key constraints were violated, other than wrong order of table data loading. It turns out almost every single table in the schema contains a trigger supposed to generate a unique row ID from a sequence on insert such as:
    CREATE OR REPLACE TRIGGER "SCHEMAX"."TABLEX#B_I_R"
    BEFORE INSERT
    ON TABLEX
    FOR EACH ROW
    DECLARE
    BEGIN
    SELECT tablex_seq.nextval INTO :NEW.ID FROM dual;
    END;
    If the import mechanism fires this trigger, and the sequences in the source and the target systems are not synchronized, then I guess that referred records a more than likely to end up with wrong ID's compared to the row ID's in the referring rows?
    Spooky. Anybody can confirm this theory?
    Yours
    Claus
    Message was edited by:
    user586249

  • Retrieve the Purchase Order Condition Records Table

    Hallo!
    I have found this code right here:
    http://www.sap-basis-abap.com/sapab025.htm
    It is very useful particular for purposes which I need. Please can somebody
    try to fix the error to get it working. There is an internal table missing.
    Regards
    Ilhan
    Retrieve the Purchase Order Condition Records Table
    select * from ekko.
           select * from konv where knumv = ekko-knumv
               "Get all the condition records for the purchase order
           endselect.
    endselect.
    * Get the info record conditions record
    * First declare the record structure for the key
    data: begin of int_konp,
                 txt1(5),
                 lifnr(5),
                 matnr(18),
                 txt2(4),
                 txt3(1),
            end of int_konp.
    clear: konh, konp, int_konp.
    * data for the record key konh-vakey
    int_konp-txt1    = '00000'.
    int_konp-lifnr    = ekko-lifnr+5(5).
    int_konp-matnr = ekpo-matnr(18).
    int_konp-txt2    = 'ALL'.
    int_konp-werks = ekpo-werks.
    int_konp-txt3    = '0'.
    select * from konh where      kschl = 'PB00'            "Conditions (Header)
                                         and datab => p_datum.       "valid from date
          if konh-vakey = int_konp.                                  "Conditions (Item)
                 select single * from konp where knumh = konh-knumh.
                 continue.
          endif.
    endselect.

    Hi flora
    Just get through the sequence .
    see the table fields ...
    1. From EKKO table take an entry which is having pricing conditions.
    Now in the fields list check out for field EKKO-KNUMV(document condition number).
    2.Take this condition number and now goto table KONV.
    Give the document condition number in the field  KONV-KNUMV and execute .
    This will lead to a list of document condition numbers and some other fields .
    3.Now check for field KONV-KNUMH ,KONV-KAWRT(quantity) and note the value KONV-KWERT  .
    (Remember this is at header level).
    This is ur condition record number.
    **comments
    Now from document condition number we got the condition record number (KNUMH).
    4. now since u want the item level tax procedure go to table KONP and give the condition record number and execute .
    This will give u a list of details .
    Now concentrate on KONV-KAWRT (scale quantity) KONP-KBETR(rate) as this table will store “Pricing  per UNIT “ so product of these two will give u the total pricing tax, for a particular condition type say PR00  .
    For that particular condition item .
    Check the pricing procedure .
    See t-code VK13 and check the pricing procedure .
    From me23 check the same PO num select the item and check the pricing conditions applicable .
    Select a particular pricing and goto condition->analysis->analysis pricing  ,
    Better take help of a SD functional consultant in the process.
    regards,
    vijay.

  • Joining tables in different databases

    Hi,
    I know we can access multiple databases like Oracle, Informix etc. through a single toplink session using session broker. Also in toplink documentation it says there is a work around for joining tables that exists in different databases i.e. joining an Oracle table with an Informix Table. If anyone had tried this or if it is possible, please let me know how to do this.
    Thanks..

    If I could know, how to perform or some sample code, for the following two steps it would be great.
    Write descriptor ammendment code to bind together that go from (A) to (B) and (B) to (A).
    Be sure to map the ammendment descriptors in the mapping workbench.Or please point me to the right toplink documentation or examples.
    Thanks a lot for your help.

  • In SQ02 after joining table if we want write condition on other field how ?

    In SQ03 after joining table if we want write condition on some fields
    for filtering records then what is the procedure.

    Please check forum subject. This is not a right forum for your question. Close your thread and post it on a proper forum.
    Thanks,
    Gordon

  • CMP additional field in join table

    I'm sorry if this question was already post on the forum, but I could not find any answer....
    I have an existing application which is using CMP entity beans.
    A and B have a many to many relation, then the relation is mapped to a join table with 2 columns (key of A, key of B)
    I need to modify this relation in order to specify the number of B linked to A for a given relation, then adding a column to the join table :
    (key of A, key of B, MyParameter)
    Is there a way to specify the parameter in the beans ?
    Do I have to change my CMP entity bean to BMP beans?
    If I do have to use BMP, many other CMP entity beans have relations with one of the beans that I will have to modify to BMP. Will I have to transform all the CMP beans with relation to BMP beans (then almost all the application) to BMP?
    Thanks a lot for your answers.

    Manohar,
    You need to create an append structure for table VBAP (for example ZAVBAP) using SE11. In this structure you create your ZZ fields. If you need a non-SAP domain/data element for your field then you need to create it first using the same transaction and activate it. Attach ZAVBAP to VBAP so the SE11 shows:
    .APPEND in the Fields column and
    ZAVBAP in the Field type column.
    Your ZZ fields will be shown automatically.
    When you have finished then activate your ZAVBAP structure. You will notice when you go VA01 (for example) that a lot of programs are being recompiled. Don't worry. It will be ok.
    The user-exit screen number for items is 8459 (in program SAPMV45A).
    Thanks,
    Wojtek

  • How do I change system settings so that users are not required to enter the mac's admin pw in order to join a wifi network?

    how do I change system settings so that users are not required to enter the mac's admin pw in order to join a wifi network?
    Right now my macbook pro requires an admin password before connecting to a new wifi network. In other words when a user that is not an admin tries to connect to a new wifi network the pop up displays indicating that it is locked and an admin password is required.
    Is there a way to remove this restriction so that a non admin can connect to wifi without the mac's admin password.

    You can enable / disable this option in System Preferences:
    System Preferences > Network > Wi-Fi > Advanced > Wi-Fi tab > Require administrator authorization to: Change networks

  • Joining tables across databases in OBIEE Physical Layer

    I was facing this problem of joining tables across databases in Physical layer of OBIEE admin tool.
    I had a requirement to combine two tables from 2 different databases A and B respectively. I had created one database object (OBIEE Object) in the physical layer and I had created two connection pools under that pointing to the required databases. I was able to view the data (right click on the table object --> popup menu option "View Data" ) though I had to go through the "Select connection Pool" window and select the required connection pool. I was able to join the tables and was able to complete the star schema in BMM and bring them up to the presentation layer. Conistency check was also successful. Everything went fine so far.
    But when I started building the report, I started getting error whenever I chose the table which was supposed to be queried by using the second connection pool. The error message was something like "table or view does not exist at OCI call OCIStmtExecute". I assume that this was happening because the systm was not able to understand which connection pool to choose (because there were two pools defined under one database object) and by default the server was choosing the first one. If anybody is having a different opinion or definite information about this, kindly update with your reply.
    I could resolve this problem after creating a separate database object with a separate connection pool defined under it, which points to the second database. Imported the required table under this database object. (Infact it was reverse. When I re-imported the table, OBIEE Admin tool, by default created its own database object and the connection pool separately for the imported table).
    Once this was done then I went ahead as usual by joining the tables across these two different database objects and modelling was already done (ofcourse with a little more tweaking since the mapping had to be redone between BMM and Physical layers). Now I could build the report in the reporting layer without encountering any error.
    Appreciate and welcome any further additions/updations/corrections regarding this issue(?).
    -MMishra.
    Edited by: user13483341 on Nov 29, 2011 8:20 AM
    Edited by: user13483341 on Nov 29, 2011 8:20 AM
    Edited by: user13483341 on Nov 29, 2011 8:24 AM

    Hi Deepak, Thanks for your reply.
    Appreciate if you can help me with another thread "possibility of multi-currency in OBIA 7.9.6.2 financial anlytics".
    - MMishra.

  • I would like to print a four sided programme, but am having trouble finding out how to organise the sections onto a 17  by 11 paper with the sections in the right order. Any help?

    I would like to print a four sided programme, but am having trouble finding out how to organise the sections onto a 17  by 11 paper with the sections in the right order. Any help?

    If all you are going to do is print double sided and them make
    a single fold reducing the page to 8 1/2 x 11, one side of the
    original 17 x 11 page will be page 4 on the left as you hold
    the page facing you and page 1 on the right, reverse side
    should be printed so top is same as top on the the first side
    and will be page 2 to the left and page 3 to the right. Pick
    up the double sided document with pages 2 and 3 facing you, fold
    left edge to meet right edge; you should now have fold on the left
    with page 1 facing up toward you, turn the page as you normally
    would and pages 2 & 3 should be in order, and one more turn brings
    you to page 4 and the fold should know be on the right. I hope this
    explains clearly enough - if not, post back and some one should
    join in with a better explanation.

  • C sharp joined tables

    I have a DataGridView made by a join of two tables ( C# - working in Visual Studio): "etapa" and "lucrare_licenta" from my database. Does smbdy know how can i update these two tables simultaneously?
    This code works ony for a table..i saw a tutorial on asktheoracle.net as an example...
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.OracleClient;
    namespace ex
    public partial class Situatie_studenti_vs_etape : Form
    public int ID_ps=0;
    private DataSet ds;
    private OracleDataAdapter da;
    public Situatie_studenti_vs_etape(int x)
    InitializeComponent();
    private void button1_Click(object sender, EventArgs e)
    string sql = "select e.* from etapa e "
    + "inner join lucrare_licenta l "
    + "on l.id_lic=e.id_lic "
    + "where l.id_stud = (select s.id_stud from student s "
    + "inner join lucrare_licenta l "
    + "on l.id_stud=s.id_stud "
    + "where nume||' '||initiala_tatalui||' '||prenume||' - id '||s.id_stud = '"comboBox1.Text"') order by e.id_etapa";
    OracleConnection conn = new OracleConnection();
    OracleCommand cmd;
    OracleCommandBuilder cb;
    conn.ConnectionString = "User Id=*****;Password=*****;Data Source=*****";
    conn.Open();
    cmd = new OracleCommand(sql, conn);
    cmd.CommandType = CommandType.Text;
    da = new OracleDataAdapter(cmd);
    cb = new OracleCommandBuilder(da);
    ds = new DataSet();
    da.Fill(ds,"etapa");
    da.Fill(ds,"lucrare_licenta");
    dataGridView1.DataSource = ds.Tables[0];
    //code for UPDATE button:
    private void button2_Click(object sender, EventArgs e)
    da.Update(ds,"etapa");
    }

    why do you expect different results this time?
    update 2 joined tables
    how can i update these two tables simultaneously?first you start by UPDATE a single table; which you do not do in posted code

  • Deleted planned order in any table??

    Hi,
    Is it possible to see the deleted planned order in any table??
    Ramagiri

    Hi,
    It is right that you will not get the planned order data which has been deleted.
    But after conversion of planned orders to process/production order the planned orders will get deleted.The planned orders data can be found fromAFPO table.But manually deleted planned order data can't be found out.
    Hope this can help.
    regards,
    kaushik

  • How to join table in LCDS

    Hello,
    How can I join tables in LCDS and show them in a datagrid?
    I run LCDS3 and tomcat.
    All help is appricitated

    If an entity has relationships, joins are implicit e.g.: A customer can have multiple orders - Having access to customer gives you access to all the orders associated with the customer. Here the joins are implicit.
    However, we don’t support randomly joining tables (that don't have a relationship in the data model) in this release. You are required to create a custom data management assembler, which gives you full control over the SQL. It is likely that the next release may support joining tables directly from the data model.
    -Anil

Maybe you are looking for

  • Problem in CRM Credit Memo replication into ECC.

    Dear all, I am Creating a Credit Memo from CRM Complaint transaction. Complaint is getting created and saved without any errors. But the same is not replicating in ECC. There are no errors in 'Transaction Error log', 'SMW01' and Inbound and Outbound

  • Any way to change picture timezones?

    Hi, I'm cleaning an older Aperture library and I've discovered a number of pictures that are listed with the incorrect timezone. Is there any way to change this after the files are already imported? To clarify: Aperture seems to store (in its own met

  • Change name of parameters output by code module

    Hi guys, I am calling this  code module everytime but pass different parameters as input  & get different results I want to customize the  Parameter Name  for the output parameters as they get saved in my report. & so I can be very specific.

  • REPORT LAYOUT QUESTION

    What is the best method of adding "space" between columns of my reports. When I create my reports, the data is often too close together, making the report hard to read. I would like to add white space between my columns. Mark

  • JDBC drivers not found---Pls help

    Hi All, Pls help me out to solve this issue I have XI 3.0 and R3 4.7 EE seperately . (Both are for education purpose) While doing  JDBC scenario, I got error <b>"JDBC drivers not found"</b> in Adapter Framework. When contacted I was told to install J