Which is more faster - IN or EXISTS?

Which is more faster - IN or EXISTS?

It depends,
but for many simple cases the optimizer generates exactly the same plan for IN and EXISTS,
so there shouldn't be any difference in speed.
explain plan for
select * from hr.jobs j
where j.job_id in ( select job_id from hr.job_history );
select * from table(dbms_xplan.display );
plan FOR succeeded.
PLAN_TABLE_OUTPUT
Plan hash value: 3539156008         
| Id  | Operation          | Name         | Rows  | Bytes | Cost (%CPU)| Time     |   
|   0 | SELECT STATEMENT   |              |     8 |   336 |     3   (0)| 00:00:01 |   
|   1 |  NESTED LOOPS SEMI |              |     8 |   336 |     3   (0)| 00:00:01 |   
|   2 |   TABLE ACCESS FULL| JOBS         |    19 |   627 |     3   (0)| 00:00:01 |   
|*  3 |   INDEX RANGE SCAN | JHIST_JOB_IX |     4 |    36 |     0   (0)| 00:00:01 |   
Predicate Information (identified by operation id):          
   3 - access("J"."JOB_ID"="JOB_ID")
15 rows selected
explain plan for
select * from hr.jobs jb
where exists (
  select 1 from hr.job_history hi
  where jb.job_id = hi.job_id
select * from table(dbms_xplan.display );
plan FOR succeeded.
PLAN_TABLE_OUTPUT
Plan hash value: 3539156008         
| Id  | Operation          | Name         | Rows  | Bytes | Cost (%CPU)| Time     |   
|   0 | SELECT STATEMENT   |              |     8 |   336 |     3   (0)| 00:00:01 |   
|   1 |  NESTED LOOPS SEMI |              |     8 |   336 |     3   (0)| 00:00:01 |   
|   2 |   TABLE ACCESS FULL| JOBS         |    19 |   627 |     3   (0)| 00:00:01 |   
|*  3 |   INDEX RANGE SCAN | JHIST_JOB_IX |     4 |    36 |     0   (0)| 00:00:01 |   
Predicate Information (identified by operation id):          
   3 - access("JB"."JOB_ID"="HI"."JOB_ID")
15 rows selected

Similar Messages

  • Which is more (faster) performance oriented? Collections or Cursor For Loop

    Hi,
    Please help me regarding a dilemma.
    Is, using a Cursor For Loop faster than a loop run upon a collection variable that was being populated using bulk collect? Why?
    Thanks in advance
    rollerz

    You can just test it by yourself. Can’t you? Ok I was bit curious to know myself so I did this…
    TEST ROUND 1
    SQL> declare
      2     ltime integer;
      3  begin
      4     ltime := dbms_utility.get_time;
      5
      6     for i in (select level from dual connect by level <= 100000)
      7     loop
      8             null;
      9     end loop;
    10
    11     ltime := dbms_utility.get_time - ltime;
    12     dbms_output.put_line('ExecTime:'||ltime/100||' seconds...');
    13  end;
    14  /
    ExecTime:.19 seconds...
    PL/SQL procedure successfully completed.
    SQL> declare
      2     ltime integer;
      3     type my_type is table of integer;
      4     lType my_type;
      5  begin
      6     ltime := dbms_utility.get_time;
      7     select level bulk collect into lType from dual connect by level <= 100000;
      8
      9     for i in 1..lType.count
    10     loop
    11             null;
    12     end loop;
    13
    14     ltime := dbms_utility.get_time - ltime;
    15     dbms_output.put_line('ExecTime:'||ltime/100||' seconds...');
    16  end;
    17  /
    ExecTime:.14 seconds...
    PL/SQL procedure successfully completed.
    TEST ROUND 2
    SQL> declare
      2     ltime integer;
      3  begin
      4     ltime := dbms_utility.get_time;
      5
      6     for i in (select level from dual connect by level <= 100000)
      7     loop
      8             null;
      9     end loop;
    10
    11     ltime := dbms_utility.get_time - ltime;
    12     dbms_output.put_line('ExecTime:'||ltime/100||' seconds...');
    13  end;
    14  /
    ExecTime:.17 seconds...
    PL/SQL procedure successfully completed.
    SQL> declare
      2     ltime integer;
      3     type my_type is table of integer;
      4     lType my_type;
      5  begin
      6     ltime := dbms_utility.get_time;
      7     select level bulk collect into lType from dual connect by level <= 100000;
      8
      9     for i in 1..lType.count
    10     loop
    11             null;
    12     end loop;
    13
    14     ltime := dbms_utility.get_time - ltime;
    15     dbms_output.put_line('ExecTime:'||ltime/100||' seconds...');
    16  end;
    17  /
    ExecTime:.13 seconds...
    TEST ROUND 3
    PL/SQL procedure successfully completed.
    SQL> declare
      2     ltime integer;
      3  begin
      4     ltime := dbms_utility.get_time;
      5
      6     for i in (select level from dual connect by level <= 100000)
      7     loop
      8             null;
      9     end loop;
    10
    11     ltime := dbms_utility.get_time - ltime;
    12     dbms_output.put_line('ExecTime:'||ltime/100||' seconds...');
    13  end;
    14  /
    ExecTime:.16 seconds...
    PL/SQL procedure successfully completed.
    SQL> declare
      2     ltime integer;
      3     type my_type is table of integer;
      4     lType my_type;
      5  begin
      6     ltime := dbms_utility.get_time;
      7     select level bulk collect into lType from dual connect by level <= 100000;
      8
      9     for i in 1..lType.count
    10     loop
    11             null;
    12     end loop;
    13
    14     ltime := dbms_utility.get_time - ltime;
    15     dbms_output.put_line('ExecTime:'||ltime/100||' seconds...');
    16  end;
    17  /
    ExecTime:.13 seconds...
    TEST ROUND 4
    PL/SQL procedure successfully completed.
    SQL> declare
      2     ltime integer;
      3  begin
      4     ltime := dbms_utility.get_time;
      5
      6     for i in (select level from dual connect by level <= 100000)
      7     loop
      8             null;
      9     end loop;
    10
    11     ltime := dbms_utility.get_time - ltime;
    12     dbms_output.put_line('ExecTime:'||ltime/100||' seconds...');
    13  end;
    14  /
    ExecTime:.16 seconds...
    PL/SQL procedure successfully completed.
    SQL> declare
      2     ltime integer;
      3     type my_type is table of integer;
      4     lType my_type;
      5  begin
      6     ltime := dbms_utility.get_time;
      7     select level bulk collect into lType from dual connect by level <= 100000;
      8
      9     for i in 1..lType.count
    10     loop
    11             null;
    12     end loop;
    13
    14     ltime := dbms_utility.get_time - ltime;
    15     dbms_output.put_line('ExecTime:'||ltime/100||' seconds...');
    16  end;
    17  /
    ExecTime:.13 seconds...
    PL/SQL procedure successfully completed.So bulk collect looks faster...
    Thanks,
    Karthick.

  • Which is better - Add a dimension or create more members in an existing

    Which is better - Add a dimension or create more members in an existing dimension?
    We are trying to figure out which can give us better performance in terms of calculations and retrieving reports - to add another dimension (entity/country) or add about 500-800 more members in an existing location/division dimension?
    Thank you!

    If you have BSO cube i would recommend to add in the same dimension where as ASO you can add members in a new dimension. Adding a new dimension is like creating a new cube you have to change each and every single calc scripts,report scripts,FR reports,Webforms and your rule files .... all the dependencies has to be changed manually . I think 500 members in the exsting BSO dimension will not impact the calc or retrieval times that much .

  • Which is fast IN or EXIST and how?

    Could any one clarify me?
    which will select data fast
    In or Exist, How it works
    Thanks

    Well read this thread completely to get teh answer.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:953229842074
    Aman....

  • How do I create my own favorite template for DVD slideshows? I used to be able to select this from pulldown menu, but cannot now do so. I am directed straight to templates, which take more memory. I have a large slideshow, and need all the space I can get

    First, how do I create my own favorite theme template for DVD slideshows? I used to be able to select this from pulldown menu, but cannot now do so. I am directed straight to already existing themes, which take more memory. I have a large slideshow, and need all the space I can get. I just want to use a picture as my DVD cover, and then insert a slideshow. Also, when I try to burn my 8.5gb double sided slideshow, all that burns is the music. It is a large slideshow, a memorial on the life of my now deceased brother. This means a lot to me and to my family, and I am having so much trouble trying to burn it. I have gone into Project View and selected appropriately. The bar shows I have room to burn this DVD, but it does not burn.  I have burned so many DVDs in the past, but this one just will not burn. I am so confused at this point. I will say this is the first 8.5gb I have attempted to create and burn. My specs list a 7.7gb or 4.7gb as operable....but there are no 7.7gb dvds. I had to purchase 8.5gb. Help? What am I doing wrong? I have spent so much time on this, and just cannot figure it out.

    Final Cut is a separate, higher end video editor.  The pro version of iMovie.
    Give iPhoto a look at for creating the slideshow.  It's easy to assemble the photos in an album in iPhoto, put them in the order you want and then make a slideshow of them.  You can select from various themes and transitions between slides and add music from your iTunes library.
    When you have the slidshow as you want use the Export button at the bottom of the iPhoto window and export with Size = Medium or Large.
    Save the resulting Quicktime movie file in your Movies folder.
    Next, open iDVD, choose your theme and drag the QT movie file into the menu window being careful to avoid any drop zones.
    Then follow this workflow to help assure the best qualty video DVD:
    Once you have the project as you want it save it as a disk image via the File ➙ Save as Disk Image  menu option. This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image, launch DVD Player and play it.  If it plays OK with DVD Player the encoding is good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    The reason I suggest iPhoto is that I find it much easier to use than iMovie (except for the older iMovie 6 HD version).  Personal preferences showing here.

  • How to add one more field to an exist internal table

    hi abapers
    i am a very new abap programmer and just started learning it.
    i want to know How to add one more field to an exist internal table.
    lemme me put my question in a very simple way.
    i have a internal table having fields f1,f2,f3 and which also that internal also contains some data.
    now i want to add two more fields (mm & nn) to that internal table now.
    how can i do that.
    and i wanna know the websites names where i can find some brain teasing questions in abap programming.
    eagerly waiting for ur reply
    regards,
    Maqsood A Khan

    Hi, MAQSOOD.
    You can insert more fields in your internal table like this.
    refer this code snippet.
    DATA : BEGIN OF tbl_itab OCCURS 0.
            INCLUDE STRUCTURE zsdtc009.
    DATA :  vkorg   LIKE vbak-vkorg,  "inserted one
            vtweg   LIKE vbak-vtweg,  "inserted one
            vkbur   LIKE vbak-vkbur,  "inserted one
            vkgrp   LIKE vbak-vkgrp,  "inserted one
           END OF tbl_itab.
    you can also read the book "Teach yourself abap in 21 days"
    at http://cma.zdnet.com/book/abap/
    but that book is just about basic concept of abap and report program.
    it doesn't give a lecture for on-line program.
    you can get pdf version books(about abap, sap...things) from sap.
    http://help.sap.com/printdocu/core/Print46c/en/Data/htm/english.htm
    I wish I could help you.
    Regards
    Kyung Woo.

  • How Can i clean my memory and make my imac more faster ?

    I am new user in mac i have imac 4 g ram  and need a way to clean the memory and make my imac more faster ...

    You can't "clean" RAM. If the "storage" space on your hard drive isn't enough then put in a larger hard drive or delete any of your data you no longer need or can store on an external drive. Beyond this I cannot say because you have not provided enough information such as the amount of installed RAM, Capacity of your hard drive and the amount of available space on the hard drive, the specific iMac model you have.
    You can try reinstalling Lion:
    Reinstalling Lion Without the Installer
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alterhatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall Lion: Select Reinstall Lion and click on the Continue button.
    Note: You can also re-download the Lion installer by opening the App Store application. Hold down the OPTION key and click on the Purchases icon in the toolbar. You should now see an active Install button to the right of your Lion purchase entry. There are situations in which this will not work. For example, if you are already booted into the Lion you originally purchased with your Apple ID or if an instance of the Lion installer is located anywhere on your computer.
    However, if your computer doesn't have enough RAM or your hard drive is full, then reinstalling won't help.

  • Update query which taking more time

    Hi
    I am running an update query which takeing more time any help to run this fast.
    update arm538e_tmp t
    set t.qtr5 =(select (sum(nvl(m.net_sales_value,0))/1000) from mnthly_sales_actvty m
    where m.vndr#=t.vndr#
    and m.cust_type_cd=t.cust_type
    and m.cust_type_cd<>13
    and m.yymm between 201301 and 201303
    group by m.vndr#,m.cust_type_cd;
    help will be appreciable
    thank you
    Edited by: 960991 on Apr 16, 2013 7:11 AM

    960991 wrote:
    Hi
    I am running an update query which takeing more time any help to run this fast.
    update arm538e_tmp t
    set t.qtr5 =(select (sum(nvl(m.net_sales_value,0))/1000) from mnthly_sales_actvty m
    where m.vndr#=t.vndr#
    and m.cust_type_cd=t.cust_type
    and m.cust_type_cd13
    and m.yymm between 201301 and 201303
    group by m.vndr#,m.cust_type_cd;
    help will be appreciable
    thank youUpdates with subqueries can be slow. Get an execution plan for the update to see what SQL is doing.
    Some things to look at ...
    1. Are you sure you posted the right SQL? I could not "balance" the parenthesis - 4 "(" and 3 ")"
    2. Unnecessary "(" ")" in the subquery "(sum" are confusing
    3. Updates with subqueries can be slow. The tqtr5 value seems to evaluate to a constant. You might improve performance by computing the value beforehand and using a variable instead of the subquery
    4. Subquery appears to be correlated - good! Make sure the subquery is properly indexed if it reads < 20% of the rows in the table (this figure depends on the version of Oracle)
    5. Is tqtr5 part of an index? It is a bad idea to update indexed columns

  • Which is more useful in include directive and taglibraries

              I am writing some static html tags inside a file.
              This files i need to call from jsp pages.
              one is i can call using include directive.
              other is writing taglibraries.
              Performance and optimization wise which is more appropriate?
              

    There is an include directive and a jsp:include tag. I would suggest that
              performance differences between these are nominal, with the directive being
              slightly faster due to its "inlining nature".
              Don't write your own tags to do this unless you have to. That would be
              silly.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              +1.617.623.5782
              WebLogic Consulting Available
              "Raaj" <[email protected]> wrote in message
              news:3af02b63$[email protected]..
              >
              > I am writing some static html tags inside a file.
              > This files i need to call from jsp pages.
              > one is i can call using include directive.
              > other is writing taglibraries.
              > Performance and optimization wise which is more appropriate?
              >
              

  • Which database is fast?

    Hi,
    I want to know that which database work fast or connect with JDBC more efficiently? I have worked on MS Access to store data. but not happy with the performance. Can anybody give me info. about other database programs like mysql, sql server, oracle or sybase. I mean which of them can be more fast with JDBC?

    It DEPENDS on what type of application you are developing. For a read-only type of website/application, mysql is BLAZING fast for reads. You also can't beat the price, FREE!!!
    If you are looking to do a heavy transaction type of application and don't want to manage the transactions yourself and let the db do it for you, then oracle is my preference (just b/c I have grown accustomed to it despite how damn expensive it is). If price is an issue you might want to look at DB2 or even Sybase. But if it is a heavy duty application then Oracle IMHO is the way to go!
    Matt Veitas

  • Query to retrieve the records which have more than one assignment_id

    Hello,
    I am trying to write a query to retrieve all the records from the table per_all_assignments_f which has more than one different assignment_id for each person_id. Below is the query i have written but this retrieves the records even if a person_id has duplicate assignment_id's but i need records which have more than one assignement_id with no duplicates for each person_id
    select assignment_id ,person_id, assignment_id
    From per_all_assignments_f
    having count(assignment_id) >1
    group by person_id, assignment_id
    Thank You.
    PK

    Maybe something like this?
    select *
    From   per_all_assignments_f f1
    where  exists (select 1
                   from   per_all_assignments_f f2
                   where  f2.person_id = f1.person_id
                   and    f2.assignment_id != f1.assignment_id
                  );Edited by: SomeoneElse on May 7, 2010 2:23 PM
    (you can add a DISTINCT to the outer query if you need to)

  • Cs5 more fast under w7 then xp , is true ?

    Hi
    i installed cs5 under w7 32bit  and under XP 32bit same machine
    and i found cs5 under w7 more fast
    i mean , zooming , refresh , curves are more active , level i see the istogram quickly
    under xp for example the zoom is sluggish , is more slow in the refresh on every layers
    same drivers,same pc
    is true ?
    did you find the same ?
    cs5 update to the last version
    thanks
    ps outside , lightroom 3 is more fast on xp

    It's not a simple "press this button" type of thing.  I've identified some 50+ things that can and should be adjusted to make Windows 7 less a toy and more serious.
    One tweak, for example, is to disable the silly and intrusive indexing, which supposedly makes searching for things faster.  Without it searches still work, but they search right now instead of relying on often outdated or corrupted index data.  And the system isn't continuously on the hard drive looking for new stuff to index.
    Another is that the system comes with a "feature" called User Access Control enabled, and for non-technical users this can help keep their system from becoming infected with malware, but for people who know what they're doing and practice safe computing (e.g., don't download every free toolbar that comes along, configure Internet Explorer to distrust everyone, that sort of thing) it can really get in the way.  Most knowledgeable people disable it.
    Personally I've disabled some of the new "gee whiz" desktop features, such as docking windows to the sides of the monitor, and Aero Peek, because I find them mentally disruptive.
    There are also some nice freeware programs like ShellFolderFix (positions Explorer windows to where they were last time), WizMouse (sends mouse events to the window the mouse is hovering over), ClassicShell (adds some classic desktop features back that Microsoft removed).
    Even such things as changing the settings of the desktop can really help - for example reducing the Window Border to 0 makes more space available to do real work.
    There are many others.  Best thing for you to do is to check back here and ask a question if you want to know how to make something work better.  Lots of experts here.
    -Noel

  • Which one is faster loading type between Insert/Update and Update/Insert?

    Hi Gurus,
    Could anyone tell me which loading type faster between Insert/Update and Update/Insert?Any resolution and document reference would be grateful.
    Regards,
    Joni

    910575 wrote:
    Thanks Purvesh for your quick response..
    Yes you are right, we have to prefer sql rather than plsql. But if i have 1 lakh records to be inserted then my insert into select will do insert one by one that mean context switching is more to server i.e 1 lakh.
    If i use BULK COLLECT+ FORALL then in a single switch the lakh records will be inserted right?
    I agree that when we have less number of records to insert we can prefer insert into select, if we have huge data then why not FORALL ?
    You have just tested for 107 records, but in huge data it is different right?
    Thanks,
    VinodYou've misunderstood how it works, I think. When you do the "insert into ... select", Oracle works out what rows need to be inserted and does them in one fell swoop. That's 2 context switches only, with the bulk of the work being done by the SQL engine.
    When you do the BULK COLLECT + FORALL, you're telling Oracle to first identify the rows (that's two context switches straight off; one from PL/SQL to SQL and then back to PL/SQL again), load them into a collection, then loop through the collection and insert the records X rows at a time (which could be all records or whatever you set as the LIMIT on the FORALL) (again, with the context switching between PL/SQL and SQL and back again through each loop).
    Which one sounds like it does the least amount of work? Not the BULK COLLECT, right?

  • Datatable update more fast!!

    Exists something that leaves the datatable update more fast?

    Hi,
    We are not able to understand your problem.
    Could you please be more elaborate.
    Thanks,
    Creator Team.

  • Implicit Join or Explicit Join...which is more efficient???

    Which is more efficient?
    An IMPLICIT JOIN
    SELECT TableA.ColumnA1,
    TableB.ColumnB2
    FROM TableA,
    TableB
    WHERE TableA.ColumnA1 = TableB.ColumnB1
    Or....An EXPLICIT JOIN
    SELECT TableA.ColumnA1,
    TableB.ColumnB2
    FROM TableA
    INNER JOIN TableB
    ON TableA.ColumnA1 = TableB.ColumnB1
    I have to write a pretty extensive query and there will be many parts and I just want to try and make sure it is efficient as possible. Can I EXPLAIN this in SQL Navigator as well to find out???
    Thanks in advance for your review and hopeful for a reply.
    PSULionRP

    Alex Nuijten wrote:
    The Partition Outer Join is very handy, but it's an Oracle-ism - Not ANSI ...Ooh, "New thing learnt today" - check.
    but then again who cares? ;)Oracle roolz! *{;-D                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for