How to re - write the join to make it faster

Hi Experts,

Will examine you please copy the following code and have your ideas.

Is there a better way to rewrite this query for best performance

Its takes 20 seconds to be less than 1,000 records in these tables.

select count(*)   
FROM inv_options opt
LEFT OUTER JOIN scott.t1v investments ON
            opt.account_id = investments.collateral_account_id AND
            opt.security_id = investments.security_id
LEFT OUTER JOIN  scott.t2v loan ON
            opt.account_id = loan.collateral_account_id AND
            (investments.settle_date = loan.hist_date OR investments.settle_date IS NULL) AND
            (investments.currency_id = loan.currency_id OR investments.currency_id IS NULL)
WHERE opt.for_principal=1






Elapsed: 00:00:00.39


Execution Plan
----------------------------------------------------------
Plan hash value: 3145385894


--------------------------------------------------------------------------------------------------------
| Id  | Operation                      | Name                  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |                       |     1 |    35 |   192   (1)| 00:00:01 |
|   1 |  SORT AGGREGATE                |                       |     1 |    35 |            |          |
|   2 |   NESTED LOOPS OUTER           |                       |    62 |  2170 |   192   (1)| 00:00:01 |
|   3 |    MERGE JOIN OUTER            |                       |    62 |  2170 |     6  (17)| 00:00:01 |
|*  4 |     TABLE ACCESS BY INDEX ROWID| inv_options           |    28 |   364 |     2   (0)| 00:00:01 |
|   5 |      INDEX FULL SCAN           | PK_inv_options        |    28 |       |     1   (0)| 00:00:01 |
|*  6 |     SORT JOIN                  |                       |    63 |  1386 |     4  (25)| 00:00:01 |
|   7 |      TABLE ACCESS FULL         | T1V                   |    63 |  1386 |     3   (0)| 00:00:01 |
|   8 |    VIEW                        | VW_LAT_5E927E13       |     1 |       |     3   (0)| 00:00:01 |
|*  9 |     TABLE ACCESS FULL          | T2V                   |     1 |    16 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------


Predicate Information (identified by operation id):
---------------------------------------------------


   4 - filter("OPT"."FOR_PRINCIPAL"=1)
   6 - access("OPT"."ACCOUNT_ID"="BALINV"."COLLATERAL_ACCOUNT_ID"(+) AND
              "OPT"."SECURITY_ID"="BALINV"."SECURITY_ID"(+))
       filter("OPT"."SECURITY_ID"="BALINV"."SECURITY_ID"(+) AND
              "OPT"."ACCOUNT_ID"="BALINV"."COLLATERAL_ACCOUNT_ID"(+))
   9 - filter("OPT"."ACCOUNT_ID"="BALLOAN"."COLLATERAL_ACCOUNT_ID" AND
              ("BALINV"."CURRENCY_ID"="BALLOAN"."CURRENCY_ID" OR "BALINV"."CURRENCY_ID" IS NULL) AND
              ("BALINV"."SETTLE_DATE"="BALLOAN"."HIST_DATE" OR "BALINV"."SETTLE_DATE" IS NULL))




Statistics
----------------------------------------------------------
       1360  recursive calls
         18  db block gets
       1447  consistent gets
        110  physical reads
          0  redo size
        542  bytes sent via SQL*Net to client
        552  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
         63  sorts (memory)
          0  sorts (disk)
          1  rows processed

any guidance how to the development of such packages?

Start by looking at the code, you can do it and we cannot (currently).

Tags: Database

Similar Questions

  • How can I write the value of floats Unitronics vision230 PLC with modbus Ethernet

    How can I write the value of type Float in unitronics PLC Vision230 modbus ethernet (Ethernet Master Query.vi MB) usinsg I read and write register 32 bits, for example, I want to write the value 23.45 2nd Add. MF. And registry MF is the 32-bit registry. I read and write register 32-bit.

    Narendra.

    Narendra,

    Two characters can type cast into a uint16 you VI supports.

    To summarize. Take one (4 bytes). Flatten it to a string (4-byte) divided this string into two parts of 2 bytes each. Cast in u16 (16 x 2 = 32-bit).

    However, if you really want to follow the IEEE standards then you will need refer this KB. His is not that simple, but seems closer to what you are looking for.

    Amit

  • How can I write the trigger for the global temporary Table

    Hi Grus,
    How can I write the trigger for the global temporary Table.

    I created the TWG with trigger using the script below.


    CREATE A GLOBAL_TEMP GLOBAL TEMPORARY TABLE
    (
    EMP_C_NAME VARCHAR2 (20 BYTE)
    )
    ON COMMIT PRESERVE ROWS;


    CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
    BEFORE DELETE, UPDATE OR INSERT
    ON GLOBAL_TEMP
    REFERRING AGAIN AS NINE OLD AND OLD
    FOR EACH LINE
    BEGIN
    INSERT INTO VALUES EMPNAME (: OLD.) EMP_C_NAME);
    END;
    /


    trigger was created successfully, but her would not insert EMPNAME Table...

    Please guide if mistaken or not? If not wanting to give a correct syntax with example


    Thanks in advance,
    Arun M M
    BEGIN
    INSERT INTO EMPNAME VALUES (:OLD.EMP_C_NAME);
    END;
    
    you are referencing old value in insert stmt.
    
    BEGIN
    INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
    END;
    

    then run your app, it works very well...

    CREATE GLOBAL TEMPORARY TABLE GLOBAL_TEMP
    (
    EMP_C_NAME VARCHAR2(20 BYTE)
    )
    ON COMMIT PRESERVE ROWS;
    
    CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
    BEFORE DELETE OR UPDATE OR INSERT
    ON GLOBAL_TEMP
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    BEGIN
    dbms_output.put_line(:OLD.EMP_C_NAME||'yahoo');
    INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
    dbms_output.put_line(:OLD.EMP_C_NAME);
    END;
    /
    
    create table EMPNAME as select * from GLOBAL_TEMP where 1=2
    
    insert into GLOBAL_TEMP values('fgfdgd');
    commit;
    select * from GLOBAL_TEMP;
    select * from EMPNAME;
    
    output:
    1 rows inserted
    commit succeeded.
    EMP_C_NAME
    --------------------
    fgfdgd               
    
    1 rows selected
    
    EMP_C_NAME
    --------------------
    fgfdgd               
    
    1 rows selected
    

    He got Arun

    Published by: OraclePLSQL on December 28, 2010 18:07

  • How can I write the data on the graph xy

    I want to write the values of x and y... how can do that... I tried with the independent cluster.but the sons weren't told connected.it that the dimensions are not same.why my watch 3 xy dimenssional table? He must have a 2d painting.

    can someone help me please...

    Ignatius

    Normal, 'Write on worksheet File.vi' required a simple table 1 d or 2D as input and not a specific type in the cluster (because the XY graph is a cluster).

    So, given that your [X] data is the same for every [Y], you could build a 2D data table to use (by implementing the 'build picture' with [X] & [Y]).

    If it is not the case (same [X] for all [Y]), you will have to proceed to another method-online 2 files or the conversion of custom text before writing.

  • Without a password how can I access the computer and make my own?

    I inherited a Mac Mini (2012, but do not have the password to the owner (departed).) How can I access and make my own?

    Follow the steps here:

    What to do before you sell or give away your Mac - Apple Support

    To restore to a factory State, set up like yours.

  • How to connect with the device to make a phone call

    Hello world

    I am developing a small application, in which I provide a button contains the phone number to let the user click on and make a phone call, I try the class phone but couldn't.

    Could someone tell me how to do this!

    Thank you!

    read this:

    http://supportforums.BlackBerry.com/T5/Java-development/phone-invocation-not-working/m-p/306554#M539...

  • How can I download the plugins and make them work

    I found a great and free with several plugin.  First, I tried to download one of the free plugins for Adobe C6.  Following all the instructions.  Then open them Adobe photoshop I opened a picture and went to change == plugins == and see listed that I had just installed, so I choose what it and said ok. is nothing happned.  So, how do you use plugins?  Can someone help me please?

    Thank you

    Thank you

    The plugin is called redfield Fractalius and I saw it on a video from Adobe for PS6 == I managed to install one of their free plugins, but when I installed the Fractalius demo he just went to his destination file, but will not do anything else == I'm new to all this, but will go back and try to review question forum.

    Thank you

    Date: Wednesday, March 12, 2014 02:05:07-0700

    From: [email protected]

    To: [email protected]

    Topic: how to download plugins and make them work

    Re: how to download plugins and make them work

    created by c.pfaffenbichler in Photoshop for beginners - discover complete discussion

    Nice day!

    If the plug-in is indeed suitable for use in Photoshop CS6 you can ask the plugin creator/s said.

    As you have not revealed which plugin you are talking about, nor what are your OS and hardware etc, it seems unlikely that you can expect a lot of relevant help here.

    Kind regards

    Pfaffenbichler

    Please note that the Forums Adobe does not accept attachments to emails. If you want to embed an image on the screen in your message please visit the thread in the forum to incorporate the image into the http://forums.adobe.com/message/6202124#6202124

    Replies to this message received to everyone subscribed to this topic, not directly to the person who posted the message. To post a reply, or reply to this email or visit the message page: http://forums.adobe.com/message/6202124#6202124

    To unsubscribe from this thread, please visit the page message to http://forums.adobe.com/message/6202124#6202124. In the Actions box to the right, click on stop Notifications by e-mail.

    Start a new discussion in Photoshop for beginners to the Adobe community

    For more information on maintaining your email forum notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • How do you rename the files that make up the VM

    Hi guys

    I need to know how to rename a virtual computer in Vsphere Client.  If I right click on the VM in Vsphere client and rename, which is not rename the folder and the files in the data store for this virtual machine.  I have rename the VM to what I want, but the folder and files inside still have the old name.  Is it possible to rename that I don't know?

    under the direction...

    Hello.

    A cold migration or a Storage VMotion will make files and directories match what you have re-named the VMS in vCenter.

    Good luck!

  • How can I write the SQL query for this requirement?

    Hello

    I have a table that looks like this:

    NAME | ANNUAL |     VALUE
    ==== | ====== | =====
    execno |     480.     000004
    step |      480.     0400
    SCNA |     480. cd_demo
    System |     480.     D47-010
    type |     480.     step
    free_text |     480.     stage 400
    rbare |     480.     RBA-1
    execno |     482. 000004
    SCNA |     482. cd_demo
    System |     482.     D47-010
    free_text |     482.     step 300
    step |          482.          0300
    type |      482.     step
    rbare |     482.     RBA-1
    execno |     483.     000001
    type |     483.     step
    rbare |     483.     rke1
    SCNA |     483.     rke10
    step |     483.     0240

    Now, say that I want to fetch ONLY annual with execno = '000004' and '400' = step and scna = "cd_demo" and system = "d47-010' and type = 'step', how to write SQL code?
    At first, it seemed like a simple writing query but I've been struggling with it for hours without success. I must admit though that I'm not strong in SQL :-)
    There, can anyone help? Please...

    Thanks in advance.

    Emmanuel

    Published by: user12138559 on October 30, 2009 03:05

    Hi, Emmanuel.

    Welcome to the forum!

    Here's a way to do what you asked:

    SELECT       doc_id
    FROM       table_x
    GROUP BY  doc_id
    HAVING       SUM (CASE WHEN name = 'execno' AND value = '000004'  THEN 1 END) > 0
    AND       SUM (CASE WHEN name = 'step'   AND value = '400'     THEN 1 END) > 0
    AND       SUM (CASE WHEN name = 'scna'   AND value = 'cd_demo' THEN 1 END) > 0
    AND       SUM (CASE WHEN name = 'system' AND value = 'd47-010' THEN 1 END) > 0
    AND       SUM (CASE WHEN name = 'type'   AND value = 'step'    THEN 1 END) > 0
    ;
    

    If you think that a WHERE clause would be used, but WHERE does apply to a single line. You need a condition that checks several rows in the same group.
    WHEN has an effect something like WHERE.

    Published by: Frank Kulash, October 30, 2009 06:26

    This solution assumes that (name, annual) is unique.

  • How can I write the symbol ' greater than or equal to "in a string or a label?

    Hello

    I tried to use the "symbol" font to create the greater or equal symbol, but it does not work.

    Does anyone know how to do this?

    Thank you

    User

    The only way I know to do, is to type in the appropriate character code (Alt-0179, using the keypad), then highlighting the unique character (in most fonts, it is the exponent 3), then change the font to "symbol".  The rest of the characters in the string will be in the same font as before, only the highlighted character will change.

  • I forgot my password of connection for windows 7 for my toshiba laptop and did not create a reset disk. How can I recover the password or make a new one?

    I forgot my password login for windows7 and I have not created a password reset disk. How can I get a new password?

    Microsoft's strategy concerning lost or forgotten passwords:

    http://support.Microsoft.com/kb/189126

    Maintaining secure passwords - Microsoft strategy on getting around passwords:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-security/keeping-passwords-secure-Microsoft-policy-on/39f56ef0-5d68-41AD-9daa-6e6019c25d37

    What to do if you forget your Windows password

    If you have forgotten your Windows password and you are on a domain, you must contact your system administrator to reset your password. If you are on a working group (the majority of individuals are on a working group), you can reset your password by using a reset disk of password or by using an administrator account.

    Create a password reset disk:

    http://Windows.Microsoft.com/en-us/Windows7/create-a-password-reset-disk

    Reset your Windows password:
    http://Windows.Microsoft.com/en-us/Windows7/reset-your-Windows-password

    If you forget the administrator password, and you do not have a password reset disk or another administrator account, you will not be able to reset the password. If there is no other user account on the computer, you will not be able to connect to Windows and you will need to re - install Windows.

    What to do if you forget your Windows password:

    http://Windows.Microsoft.com/en-us/Windows7/what-to-do-if-you-forget-your-Windows-password

    Solutions to common problems with logging on Windows:

    http://Windows.Microsoft.com/en-us/Windows7/solutions-to-common-problems-with-logging-on-to-Windows

    Recently changed the password? Use the system restore and restore point from before it was modified:

    http://Windows.Microsoft.com/en-us/Windows7/what-are-the-system-recovery-options-in-Windows-7

    Change your Windows password:

    http://Windows.Microsoft.com/en-us/Windows7/change-your-Windows-password

  • How can I write the SQL for this result?

    Hello my dear,
    Here first of all the script.
    CREATE TABLE ACC_TEST(
    AD_ID NUMBER,
    AD_NAME VARCHAR2(50),
    AD_SPM_ID NUMBER);
    /
    the data are
    Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (136,'Saleh Ahmed',129);
    Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (142,'Hamidur Rahman',136);
    Insert into ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) values (124,'Jasim Uddin',null);
    INSERT INTO ACC_TEST (AD_ID,AD_NAME,AD_SPM_ID) VALUES (129,'Sazib',124);
    I need the following result, when passing a value of Ad_Id. For example I go to 142 then result must be
    Select Ad_Id,Ad_Name
    From..
    ...
    where ad_id=142
    
    Ad_Id   Ad_Name
    136     Saleh Ahmed
    129     Sazib
    124     Jasim Uddin
    
    If I Pass Ad_Id=136 Then Result Should Be
    Ad_Id   Ad_Name
    129     Sazib
    124     Jasim Uddin
    
    
    If I Pass Ad_Id=129 Then Result Should Be
    Ad_Id   Ad_Name
    124     Jasim Uddin 
    Database 10 G XE

    Any help will be useful

    Hello

    HamidHelal wrote:
    WoW! You are totally my point. How do you understand that? l

    Guess luck. Guessing is generally not the best way to solve problems. It is generally faster and more reliable to say exactly what you want, as well as give an example.

    fallen little more that I want to know, if I want to restrict the output not more then 2, which would be sql?

    Now, you're not even giving for example!
    Maybe you want something like this:

    SELECT     ad_id
    ,     ad_name
    FROM     acc_test
    WHERE     LEVEL     BETWEEN 2 AND 3          -- Changed
    START WITH     ad_id     = :target_ad_id
    CONNECT BY     ad_id     = PRIOR ad_spm_id
    ;
    

    which will show just the mother and grandmother of the given line.

    I work with the developer of forms a lot. Knowledge of SQL is like sql oracle (9i cerfitication) book. But this type of sql is not available here.
    where can I learn this type of sql? SQL different then regular?

    Certification is another matter entirely.
    There are books and web sites dealing with more advanced techniques. Sorry, I don't know any good enough to recommend. Some authors (such as Tom Kyte) are always good.

    Here are a few sites that explain CONNECT BY queries:
    http://www.adp-GmbH.ch/ora/SQL/connect_by.html
    http://www.oradev.com/connect_by.jsp

  • How can I fix the join table dotted outline style?

    I kept super organized when setting up my styles to table this time. I put as much as possible in the configuration of the tracked table of cell styles for some of the columns and some lines (like subdivisions). The problem with cell styles, is that you cannot set cells of running styles, only around them. So if there is a setting to do at the macro level, I would be really happy. I always get problems with formatting applied when I apply a too large number of styles or substitutions, that's what I'm trying to avoid.

    Here's the problem: table styles are still process my shots at the level of the individual cell. I use dotted in the columns, but there is no seal between the rows. They line you up at the top and at the bottom of each cell. See gray lines in this example (blue dots are bullets, not shots):

    Screen shot 2012-10-02 at 2.28.38 PM.png

    But when I replace the column and redo the outline in the outline palette, they look as expected. Compare the cells highlighted (black) to the existing table style (lines white gray and light):

    Screen shot 2012-10-02 at 2.32.05 PM.png

    Is there a setting somewhere that I'm missing? Any suggestions apart from the hand control?

    Note: I'm in CS6 on Mac 10.6, where it is important.

    In fact, I need cell styles. This is what distinguishes my font, spacing and GREP styles.

    I found the solution today. In the style of table or the table setting, I needed the "race drawing of mark" 'column Strokes in Front. Even if it has been previously set to 'Best joins' and I had no hits for lines or for table borders, was not simply giving priority to my columns dotted.

    Thanks for your reply though!

  • How can I disable the configuration that makes me type in name of user and password each time I send or reply to an email?

    Every time I have send an email, any email or answer to one, I have a symbol (maybe from the OS X keychain?) which is forces me to put in name of username/password before my email send. A lot of time and unnecessary.

    I just set up a verification of the signature in Adobe and think that it is the source, but it could be a bunch of OS X that has somehow been touched by the signatures of my safety. Can anyone help?

    Hi janteve,

    If you have the option to remember the password please check it after you have entered the user name & password.

    Otherwise, I will recommend you to contact Mac support team to get this problem resolved as they specialize on the devices out there.

    Kind regards
    Nicos

  • How can you write a time interval in the timer for User Interface?

    Use a timer on a control panel, that triggers a callback function to the sample data.  I would like to read a digital input from the user interface panel and then set this value in the interval of the timer.  But how do you write the interval of timer?  Obvious function doesn't seem to work,

    SetCtrlVal (panelHandle, PANEL_TIMER, %SAMPLESECONDS%);

    Probably the best place to start is with the help of high level for the control that you are interested in.   I usually just to go to the index tab in help, start typing the name of the control (timer in this case) and then choose the top level help topic.  From here, you can see the attributes that you can use the events you can capture, programming concepts, etc.

    NickB

    National Instruments

Maybe you are looking for

  • Can't post pictures on blogger with firefox more

    Since I updated to Firefox 29,0,1 OSX 10,8.5 I can't use Firefox to post pictures on Blogger (blogspot) more. Buttons to select the images to upload pictures on Blogger, but they never show in positions. I solved the problem using Safari... but I'd l

  • Vista Update Failed facilities, 643 error code

    I can't update or install anything. Whenever I try to update Windows, installation is running, and then gives an error of "some updates not installed. Code 643. Has encountered an unknown error. » If I try to update iTunes or other programs/applicati

  • Vista - I have Windows Mail but receive Outlook 2002 update

    I received today an Outlook 2002 update... I don't have Outlook 2002, I have Windows Mail. Why have I not this update?

  • How to use a micro card SDHC 8 GB Clip +.

    Hi people, I have this right? In order to play additional music on the clip +... 1 for example, buy a microSDHC 8 GB card and an adapter 2 plug it into a PC (will appear that out when I get a card) 3 format FAT32 4 music to tranfer to clip +. 5. make

  • HP officejet 8600 more

    When I use the ADF to copy and scan, I have a vertical line that appears on my digitized and copies. The line running along the copying or scanning.  He doesn't have a line when I copy or scan from the glass. How can I can solve this problem