In  a SQL query whihc has join, How to reduce Multiple instance of a table

in a SQL query which has join, How to reduce Multiple instance of a table
Here is an example: I am using Oracle 9i
is there a way to reduce no.of Person instances from the following query? or can I optimize this query further?
TABLES:
mail_table
mail_id, from_person_id, to_person_id, cc_person_id, subject, body
person_table
person_id, name, email
QUERY:
SELECT p_from.name from, p_to.name to, p_cc.name cc, subject
FROM mail, person p_from, person p_to, person p_cc
WHERE from_person_id = p_from.person_id
AND to_person_id = p_to.person_id
AND cc_person_id = p_cc.person_id
Thnanks in advance,
Babu.

SQL> select * from mail;
        ID          F          T         CC
         1          1          2          3
SQL> select * from person;
       PID NAME
         1 a
         2 b
         3 c
--Query with only ne Instance of PERSON Table
SQL> select m.id,max(decode(m.f,p.pid,p.name)) frm_name,
  2         max(decode(m.t,p.pid,p.name)) to_name,
  3         max(decode(m.cc,p.pid,p.name)) cc_name
  4  from mail m,person p
  5  where m.f = p.pid
  6  or m.t = p.pid
  7  or m.cc = p.pid
  8  group by m.id;
        ID FRM_NAME   TO_NAME    CC_NAME
         1 a          b          c
--Expalin plan for "One instance" Query
SQL> explain plan for
  2  select m.id,max(decode(m.f,p.pid,p.name)) frm_name,
  3         max(decode(m.t,p.pid,p.name)) to_name,
  4         max(decode(m.cc,p.pid,p.name)) cc_name
  5  from mail m,person p
  6  where m.f = p.pid
  7  or m.t = p.pid
  8  or m.cc = p.pid
  9  group by m.id;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 902563036
| Id  | Operation           | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT    |        |     3 |   216 |     7  (15)| 00:00:01 |
|   1 |  HASH GROUP BY      |        |     3 |   216 |     7  (15)| 00:00:01 |
|   2 |   NESTED LOOPS      |        |     3 |   216 |     6   (0)| 00:00:01 |
|   3 |    TABLE ACCESS FULL| MAIL   |     1 |    52 |     3   (0)| 00:00:01 |
|*  4 |    TABLE ACCESS FULL| PERSON |     3 |    60 |     3   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
   4 - filter("M"."F"="P"."PID" OR "M"."T"="P"."PID" OR
              "M"."CC"="P"."PID")
Note
   - dynamic sampling used for this statement
--Explain plan for "Normal" query
SQL> explain plan for
  2  select m.id,pf.name fname,pt.name tname,pcc.name ccname
  3  from mail m,person pf,person pt,person pcc
  4  where m.f = pf.pid
  5  and m.t = pt.pid
  6  and m.cc = pcc.pid;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 4145845855
| Id  | Operation            | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT     |        |     1 |   112 |    14  (15)| 00:00:01 |
|*  1 |  HASH JOIN           |        |     1 |   112 |    14  (15)| 00:00:01 |
|*  2 |   HASH JOIN          |        |     1 |    92 |    10  (10)| 00:00:01 |
|*  3 |    HASH JOIN         |        |     1 |    72 |     7  (15)| 00:00:01 |
|   4 |     TABLE ACCESS FULL| MAIL   |     1 |    52 |     3   (0)| 00:00:01 |
|   5 |     TABLE ACCESS FULL| PERSON |     3 |    60 |     3   (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|   6 |    TABLE ACCESS FULL | PERSON |     3 |    60 |     3   (0)| 00:00:01 |
|   7 |   TABLE ACCESS FULL  | PERSON |     3 |    60 |     3   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   1 - access("M"."CC"="PCC"."PID")
   2 - access("M"."T"="PT"."PID")
   3 - access("M"."F"="PF"."PID")
PLAN_TABLE_OUTPUT
Note
   - dynamic sampling used for this statement
25 rows selected.
Message was edited by:
        jeneesh
No indexes created...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How to populate multiple entries to Bapi Table

    Hi all,
      How to populate multiple entries to Bapi Table.....
    Here is the code(in component controller)
      Z_Recr_Apply_Point_Input request = new Z_Recr_Apply_Point_Input(WDModelScopeType.TASK_SCOPE);
           int  size = wdContext.nodeApplicants().size();
                for(int i = 0 ; i < size ; i++)
                    String isselected = wdThis.wdGetContext().nodeApplicants().getElementAt(i).getAttributeAsText("Appl_Number");
                     if(isselected == "true")
                               com.models.veteranpoint.Zrecr_Aplno appid = new
                                    com.models.veteranpoint.Zrecr_Aplno();                                        
                                    appid.setAppl_Number(wdContext.nodeApplicants().
                                        getApplicantsElementAt(i).getAppl_Number());
                               request.addApplicants(appid);
    I want to pass the selected input field to bapi..
    Please tel me where i pass the input field...
    Please correct my code...
    Thanks & regards
    Mathi s

    Hi,
    Steps to insert multiple entries to BAPI table.
    1.Create an instance for BAPI input
    2.Bind the instance to the Node of the BAPI input
    3.Create instance of the Structure(BAPI table) to which input has to be added.
    4.Set the input values to the Structure instance.
    5.Add the instance to the BAPI input.
    6.Execute
    From the given example,I assume Z_Recr_Apply_Point_Input  is the BAPI Input and com.epiuse.us.recruitment.models.veteranpoint.Zrecr_Aplno as Structure
    Step 1:
    Z_Recr_Apply_Point_Input request = new Z_Recr_Apply_Point_Input(WDModelScopeType.TASK_SCOPE);
    Step 2:
    <b>wdContext.nodeZ_Recr_Apply_Point_Input.bind(request);</b>
    Steps 3 & 4:
    int size = wdContext.nodeApplicants().size();
    for(int i = 0 ; i < size ; i++)
    String isselected = wdThis.wdGetContext().nodeApplicants().getElementAt(i).getAttributeAsText("Appl_Number");
    if(isselected == "true")
    com.epiuse.us.recruitment.models.veteranpoint.Zrecr_Aplno appid = new
    com.epiuse.us.recruitment.models.veteranpoint.Zrecr_Aplno();
    appid.setAppl_Number(wdContext.nodeApplicants().
    getApplicantsElementAt(i).getAppl_Number());
    <b>wdContext.currentZ_Recr_Apply_Point_InputElement().modelObject().addRecr_Aplno(appid);</b>
    Step 5:
    <b>wdContext.currentZ_Recr_Apply_Point_InputElement().modelObject().execute();</b>
    Regards,
    Viji Priya

  • Multiple instances of a table & join supported in OBIEE SQLQuery report

    Hello All,
    I am creating a report in BIP based on the RPD created in OBIEE.
    I have to use multiple instances of same table in this case. But when I do that, I am getting "'The query contains a self join/This is a non-supported operation" error.
    Have anybody got his error before? Could anybody help me solving this?
    Thanks
    Narasimha Rao

    Hello All,
    I am creating a report in BIP based on the RPD created in OBIEE.
    I have to use multiple instances of same table in this case. But when I do that, I am getting "'The query contains a self join/This is a non-supported operation" error.
    Have anybody got his error before? Could anybody help me solving this?
    Thanks
    Narasimha Rao

  • How to create multiple instance on same database

    Hi ,
    I would like to know how to create multiple instance on same database . I know that some people use database configuration assistant to do this but i could not figure out how they did it.
    Any how if some one can help me with this and can give me links of this it would be great help for me.
    Thank you for reading my problem and helping me !
    Amil
    please if possible mail me on [email protected]

    How to create multiple instance?????Do you mean multiple instances on the same database, or multiple databases on the same machine ?
    I m new to this field....
    Willin to learn a lot about oracle....Then it wouldn't be bad reading a bit of Database Concepts

  • How to allow multiple instances of air desktop application

    hi all
    Adobe air desktop application only allow single instance of
    application. How to allow multiple instances like in other desktop
    applications?.
    thanks

    Thanks a lot morgair, i will check with exe4j tool.
    Actually the problem is, thread is not waiting for second request.
    thatswhat i thought it may because of thread.
    Thanks & Regards
    Sudha

  • Can we use Data Pump to export data, using a SQL query, doing a join

    Folks,
    I have a quick question.
    Using Oracle 10g R2 on Solaris 10.
    Can Data Pump be used to export data, using a SQL query which is doing a join between 3 tables ?
    Thanks,
    Ashish

    Hello,
    No , this is from expdp help=Y
    QUERY                 Predicate clause used to export a subset of a table.
    Regards

  • How to reference multiple instances of the same Java object from PL/SQL?

    Dear all,
    I'm experimenting with calling Java from PL/SQL.
    My simple attempts work, which is calling public static [java] methods through PL/SQL wrappers from SQL (and PL/SQL). (See my example code below).
    However it is the limitation of the public static methods that puzzels me.
    I would like to do the following:
    - from PL/SQL (in essence it needs to become a forms app) create one or more objects in the java realm
    - from PL/SQL alter properties of a java object
    - from PL/SQL call methods on a java object
    However I fail to see how I can create multiple instances of an object and reference one particular object in the java realm through public static methods.
    My current solution is the singleton pattern: of said java object I have only 1 copy, so I do not need to know a reference to it.
    I can just assume that there will only ever be 1 of said object.
    But I should be able to make more then 1 instance of an object.
    To make it more specific:
    - suppose I have the object car in the java realm
    - from PL/SQL I want to create a car in the java realm
    - from PL/SQL I need to give it license plates
    - I need to start the engine of a scpecific car
    However if I want more then 1 car then I need to be able to refrence them. How is this done?
    Somehow I need to be able to execute the following in PL/SQL:
    DECLARE
    vMyCar_Porsche CAR;
    vMyCar_Fiat CAR;
    BEGIN
    vMyCar_Porsche = new CAR();
    vMyCar_Fiat = new CAR();
    vMyCar_Porsche.setLicensePlates('FAST');
    vMyCar_Porsche.startEngine();
    vMyCar_Fiat.killEngine();
    END;
    Thanks in advance.
    Best Regards,
    Ruben
    My current example code is the following:
    JAVA:
    ===
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED CODAROUL."RMG/BO/RMG_OBJECT" as package RMG.BO;
    public class RMG_OBJECT {
    private static RMG_OBJECT instance = new RMGOBJECT();
    private String rmgObjectNaam;
    private RMG_OBJECT(){
    this.rmgObjectNaam = "NonDetermined";
    public static String GET_RMGOBJECT_NAAM () {
    String toestand = null;
    if (_instance == null) {toestand = "DOES NOT EXIST";} else { toestand = "EXISTS";};
    System.out.println("instance : " + toestand);
    System.out.println("object name is : " + _instance.rmgObjectNaam);
    return _instance.rmgObjectNaam;
    public static Integer SET_RMGOBJECT_NAAM (String IN)
    try
    _instance.rmgObjectNaam = IN;
    return 1;
    catch (Exception e)//catch
    System.out.println("Other Exception: " + e.toString());
    e.printStackTrace();
    return 5;
    } //catch
    PL/SQL Wrapper:
    ==========
    CREATE OR REPLACE FUNCTION CODAROUL.SET_RMGOBJECT_NAAM(NAAM IN VARCHAR2) return NUMBER AS
    LANGUAGE JAVA NAME 'RMG.BO.RMG_OBJECT.SET_RMGOBJECT_NAAM (java.lang.String) return java.lang.Integer';
    Calling from SQL:
    ==========
    CALL dbms_java.set_output(2000);
    select CODAROUL.GET_RMGOBJECT_NAAM() from dual;
    Edited by: RubenS_BE on Apr 6, 2012 5:35 AM
    Edited by: 925945 on Apr 6, 2012 5:41 AM

    You can do this by manually creating a new iterator binding in your binding tab.
    So instead of dragging the VO directly to the page, go to the binding tab, add a new executable iterator binding, and point to that one from your ELs in the page itself.

  • How to store Multiple Ec\xcels into Table Using sql loder

    Plese guide me to store Multiple Ec\xcels into Table Using sql loder

    I am not clear with your question. Do you want to load multipel Excel Files into a table. If so you can follow this link.
    http://www.orafaq.com/wiki/SQL*Loader_FAQ#Can_one_load_data_from_multiple_files.2F_into_multiple_tables_at_once.3F
    Thanks,
    Karthick.

  • How to update multiple records in the table using POST parameters:

    i got this idea from this website:http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-s ingle-sql-query/comment-page-1/#comment-5409. Basically i am trying to update all the status in the results page, and by adding $i in front of the id in the text fields, and checkboxes, i can name the different inputs with different names:
    The image of how it takes the inputs is shown here:http://forums.adobe.com/thread/709034?tstart=0
    I tried this but got this error:Parse error: syntax error, unexpected T_IF, expecting ')' in C:\xampp\htdocs\Database Query\results_change.php on line 51
    will not work in the update code section:
    for($i=0;$i<$maxRows_Recordset1;$i++)
    {$a=sprintf("%s",GetSQLValueString($_POST['changeid $i'],"int"));
    $b=sprintf("%s",GetSQLValueString($_POST['checkbox $i'],"text"));
    $display_order .= array(
        $a => $b
    if($i<$maxRows_Recordset1-1)
    $ids = implode(',', array_keys($display_order));
    $updateSQL = "UPDATE `change` SET Status = CASE Change_id ";
    foreach ($display_order as $a => $b) {
        $updateSQL .= sprintf("WHEN %d THEN %s ", $a,$b);
    $updateSQL .= sprintf("END WHERE `Change_id` IN ($ids)");

    Hi,
    Try
    BEGIN
      FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
        UPDATE xx_test
        SET checkbox = 'Y'
        WHERE rec_no = APEX_APPLICATION.G_F03(i);
      END LOOP;
    END;Code loops all checked checkbox. You do not need commit on page process.
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • How to run multiple Instances of wls5.1 under one instance

    Hello forum,I want to make 3 instance of weblogic that runs under one instance,but
    i don't know how.
    for example I will like to have the following.
    Weblogic is my main instance,so i will like to have more instances called web,db,batch
    witch run on their own under.
    Weblogic/web,db,batch,
    I have made the 4 instance first weblogic has empty weblogic.properties file,
    and the otheres 3 have their full weblogic.properties,my problem is how can I
    refer eatch instance individually, that means the
    subinstances like web,db,batch in my startweb.cmd,startdb.cmd,startbatch.cmd
    I don't know how to start eatch instance alone.
    HELP

    To run more than 1 instance of Logic at the same time, you really need 2 copies as while the license allows you to install on 2 machines (1 laptop 1 desktop ideally), they can not run at the same time.
    So, where now? Well there is a legitimate way around this, assuming you have a fast enough network between the 2 computers and that is to have 1 machine running as a Logic Node to share the work out. When I'm not 'Out and about' I could use the MacBook Pro as a node for my home setup (For example) running some of the soft synths for example.

  • How to use multiple instances in Oracle CRM On Demand

    Hi,
    Just wanted to know if we can have multiple instances in Oracle CRM On Demand? Our company has bought licenses for Oracle CRM On demand and have received a single link for the development / staging, but we have two seperate business units that will be using this systems and their processes are completely different....I thing i wanted to ask is if we can have a sub system within a big system without both interfering into each others processes.
    I hope it makes sense.
    Thanks
    Ahmed

    Hi Ahmed,
    This might be quite possible. Again, it depends on the organizational and technical complexity of both these BU's.
    1. There can be different processes in different geographies in which your application might be used. Inorder to achieve this in a single instance of CRM On Demand.
    There can be some fields that are specific to certain region, in that case you can use Roles, Access Profiles, Dynamic Layouts to change the Fields of the layouts which will allow the user to enter/read information specific to only that user.
    2. Workflows can be used to trigger an event only for users in certain BU defined in your application.
    Also the Sales Process is specific to a Role and by configuring them correctly you can make these processes fit your requirements.
    3. There are somethings that always remain the same though, like Accounts, Contacts , other entities and the pre-defined relationships, their names. Off-course these can be modified but when modified they apply through the applications. So you won't be able to have different names to the Account entity in the Major BU and the subset BU.
    I would suggest you get in touch with Oracle Expert Services if you are looking to get more details on how you can make best out of a single instance.
    Good Luck!
    Royston

  • How to reduce the size of System tables(RS*) in SAP BW?

    Hi All,
    We need to reduce the size of a system tables(RS*) in SAP BW system without impacting anything to system.
    Could you please let us know is there any Global program/Function module to do the same.
    If not if you know any individual program or other way to reduce the system table size it will be very much useful.
    Sample System tables(RS*) are given below.
    RSHIENODETMP
    RSBERRORLOG
    RSHIENODETMP~0
    RSBMNODES
    RSBKDATA
    RSBMNODES~001
    RSRWBSTORE
    RSBMLOGPAR
    RSBERRORLOG~0

    Sudhakar,
    There are tables you can archive / clean up and then there are tables you cannot do anything about. For example - if your system has a million queries - the RSRREPDIR , RZCOMPDIR tables will be large.
    The tables that typically get archived are :
    1. BALDAT / BALHDR - application log tables
    2. Monitor tables - search for Request archiving which will tell you how to archive the same
    The other tables -
    First you would have to understand why they are large in the first place ... if you have too many hierarchies - then some tables can be huge - delete some of the hierarchies you do not need and the table sizes should come down.
    RSRWBSTORE - this is the internal store for workbooks - this will have the last executed version of the workbook stored in the table. This information is called when the workbook is executed without refreshing the variables - which is why you get the workbook output first and then get prompted to refresh the variables.

  • How to use multiple instances of the same dll ?

    Hi,
    I'd like to use multiple instances of a jni dll . I have created
    different threads, in each thread, I have called System.loadLibrary(..),
    and I would like each thread to access a different instance of this
    library.
    Unfortunately, the loadLibrary function is effective only once so I
    can not find the way to do this.
    Can anyone help me on this ?
    Thanks.
    Francois.

    Hi, :)
    and I would like each thread to access a different
    instance of this library.In Win32, this is outright impossible. A DLL will only exist once in a process space.
    In Unix, or at least in Solaris, I think this is also not possible, as libraries are loaded by the dynamic linker, and it keeps tabs of which modules have already been loaded into the process space.
    I'm assuming your problem is that your native library has non-reentrant code.
    If so, there are two approaches you can take to this:
    1) If you have access to the source code for the native library, change it so that it is reentrant.
    2) If you do not, change your Java code so that access to the native code is made from whithin synchronize blocks.
    If your problem is of a different nature, I'll second the words of the previous poster and ask you what it is...
    Cheers,
    J.

  • How to Patch Multiple Instances on same oracle home

    Hi All
    I Have 4 Instances running on server like below
    DEVSTAG /opt/oracle/product/10.2.0
    DEVUAT /opt/oracle/product/10.2.0
    DEVREVT /opt/oracle/product/10.2.0
    DEVREG /opt/oracle/product/11.2.0
    i want to Apply the patch set 11.1.0.7.1 to DEVUAT & DEVREVT Instances , Can someone please help .. i dont want this patch set applied to DEVSTAG Instance .. how to exclude that Instance from getting patched ?
    Thanks in advance .. hope my requirement is clear.

    Which patch are you referring to ? The database patching tool (opatch) generally applies any database patch to an ORACLE_HOME. You will need to follow the instructions in the README of the patch. If you need to only patch one instance, then you will have to create a dedicated ORACLE_HOME for each database (i.e they will not share database executables). If you share ORACLE_HOME amongst multiple instances, then you will have to patch all of them simultaneously.
    HTH
    Srini

  • How to delete multiple rows from ADF table

    How to delete multiple rows from ADF table

    Hi,
    best practices when deleting multiple rows is to do this on the business service, not the view layer for performance reasons. When you selected the rows to delete and press submit, then in a managed bean you access thetable instance (put a reference to a managed bean from the table "binding" property") and call getSeletedRowKeys. In JDeveloper 11g, ADF Faces returns the RowKeySet as a Set of List, where each list conatins the server side row key (e.g. oracle.jbo.Key) if you use ADF BC. Then you create a List (ArrayList) with this keys in it and call a method exposed on the business service (through a method activity in ADF) and pass the list as an argument. On the server side you then access the View Object that holds the data and find the row to delte by the keys in the list
    Example 134 here: http://blogs.oracle.com/smuenchadf/examples/#134 provides you with the code
    Frank

Maybe you are looking for

  • Flashing Green/Yellow Light & using my iPod for the first time

    * Quick solution to my woes, and explanation afterwards* Follow instructions exactly. Do not attempt to do anything else unless specified. Make sure you have Win XP with SP 2, and verify that your USB ports are working before proceeding. Reboot the m

  • Exchange rate field greyed out when i use custom PO order type

    Hi! Upon creation of PO using SAP standard order type NB, the field exhange rate is editable. While when i used csutom PO order type, it is greyed out. How can we edit this? Where is the configuration of the exchange rate per order type? If this is c

  • PDF Downloads are all defaulting to a Firefox image & will not open

    When I save (download) PDF files, they display a Firefox image in my Downloads folder. When I click on the image instead of opening the file, Firefox opens a new tab. How do I change the download default to Adobe instead of Firefox? It used to work;

  • Insalling 32 & 64 bit clients in Windows 7 64bit OS

    Hi, We are using Windows 7 64bit OS. We have both 32 bit and 64 bit applications accessing our Oracle 10g server. Some applications are listed bellow. 1) Forms 6i 32 bit 2) 32 bit VB6 application 3) Office VBA applications 4) Autocad 64 bit VBA 5) AS

  • An error occurred while I was updating my Ipad

    I got an error when i was updating my ipad and the update aborted itself and now my itunes wont recognize my ipad and my ipad has been restored.  My ipad just sits there with the "plug into itunes" pictures and my itunes doesnt recognize it.  I have