Which method is better, the SELECT .. CURSOR(.. , or the Queries in loop

I have a table t1, this table has 1 to many relation with
tables t2,t3. t2,t3 do not have any direct relation with eachother.
I have to read all data in all tables, what do you prefer
from the following. I am using 10g release 2 but if there
is some better way in 11g I can go for it also.
Also generalize this for t2,t3,t4,t5,... etc.
Method 1.
FOR i in (SELECT * FROM T1) LOOP
FOR j in (SELECT * FROM t2 WHERE t2.x=t1.x)LOOP
...process data...
END LOOP
FOR k in (SELECT * FROM t3 WHERE t3.x=t1.x)LOOP
...process data...
END LOOP
END LOOP;
Method 2
FOR i in
(SELECT t1.*,
CURSOR(select * from t2 where t2.x=t1.x),
CURSOR(select * from t3 where t3.x=t1.x)
FROM t1) LOOP
... process data...
END LOOP
Which one will be the faster and why.
Thanks

Your question is meaningless.
Why? Because...
> There is no way to join all these 3 tables correctly, because joining will
produce reduandant rows.
and...
> its impossible to join all three tables here
and then you show Method 1 and 2 as options.
Guess what.
You have coded a nested loop join in both!
So just what makes your hack of a join in PL/SQL so much superior than an "impossible" nested loop join in SQL?
Your problem is not joining.. it is conceptual and design fundamentals. Your approach says that the problem should be approached by discarding the fundamental concept of joining data in a RDBMS.. and thinking of row-by-row slow-by-slow serialised processing.
Join. Use parallel processing. Either PQ or self-rolled via PL/SQL. There are loads of tools in the Oracle toolbox to address this type of problem.
Message was edited by:
Billy Verreynne

Similar Messages

  • Which method is better to the performance?

    Using SQLs at front side or using stored procedures at back side, which method is better to the performance?

    jetq wrote:
    In my view, it maybe have other difference, for example,
    Using stored procedure, you don't need to recompile the script every time to be executed,
    and use the existing execute plan.what if first time procedure is called after DB start?
    PL/SQL does not have EXPLAIN PLAN; only SQL does.
    But using SQL statement from application layer may be different.different than what exactly.
    SQL is SQL & can only be executed by SQL Engine inside the DB.
    SQL statement does not know or care about how it got to the DB.
    DB does not know or care from where SQL originated.

  • Which tablet is better the Kindle or Samsung ?

    My family would like to replace our Nook tablets with either a Kindle Fire HDX or a Samsung Galaxy Tab.  I have my own and my 2 kids each have their own.  I like to know which one is better the KIndle or the Samsung?

    Well this is an easy one, the Samsung is by far more broader in what you can do and is a favorite among many people for different reasons. The tablet is great is for small business/personal use. I would encourage you to lean more towards it for several reasons.
    If I may though, I would wait until the end of the year before I consider a new one as September is generally when Samsung releases new products.
    I am not affiliated with Best Buy nor have I ever been employed by Best Buy. All of my thoughts and posts are of my own opinion and personal experience.
    I may not always know the right answer, but I will always tell you what I do know. I also do free computer analysis and consultation via private message.

  • How find which method-class will be selected?

    Hello sap gurus,
    I have another question:
    There are 2 the same methods: customer_exit_event_save, BUT in different classes.
    One for the class CL_EX_BCA_PO_CUSTOMER_EXIT, another from the class ZCL_IM_BCA_PO_CUSTOMER_EXI
    Not fully clear how the system decide which exactly method should be executed.
    Hereby  having executed a code(see below) in one case we are executing a  method: customer_exit_event_save from the class CL_EX_BCA_PO_CUSTOMER_EXIT,
    In the another case u2013 the same method customer_exit_event_save, BUT from the class ZCL_IM_BCA_PO_CUSTOMER_EXI !!!
      IF NOT g_exit_obj_cust_exit IS INITIAL.
        CALL METHOD g_exit_obj_cust_exit->customer_exit_event_save
          EXPORTING
            flt_val         = l_flt_country
            i_header        = l_str_po_hd
            i_sender        = l_str_po_snd
            i_receiver      = l_tab_po_rcv
            i_payment_note  = l_tab_po_nt
            i_item_info     = l_str_item_info
          IMPORTING
            e_header        = l_str_po_hd
            e_sender        = l_str_po_snd
            e_receiver      = l_tab_po_rcv
            e_note          = l_tab_po_nt
          EXCEPTIONS
            raised_customer = 1.
    Do we have any table, where spesific method is selected?
    Many thanks in advance.
    Edited by: Paul Birch on Oct 16, 2008 2:50 PM

    Hello,
    You may execute SE24 to goto Class definition for both classes, go to methods tab and drilldown into the code of the method. Apply a break-point here in both cases and execute your main program which calls the method. Based on the break-point hit, you can decide as to which global class method was called.
    Hope this helps.
    Thanks,
    Venu

  • Which method signature is the best?

    Among the following method signatures in Java, which one can provide the best performance while the method is called? Why?
    (1) public void my_method( String a, int b, int c )
    (2) public void my_method( int b, String a, int c )
    (3) public void my_method( int b, int c, String a )

    1) All primitive types (except long and double) are pushed onto the stack as 32-bit entities and are 32-bit aligned. The reference types are pushed as a reference and occupy 32-bit also.
    2) If the method have had tens or hundreds of parameters, the opcodes for accessing some parameters will have short offsets and other parameters will have long offsets. When you have only 3 or 4 parameters there is no difference between the offsets needed to access each parameter. The difference of time used for the interpreter or JIT compiler for dealing with short or long offsets usually is negligible.
    3) So the better way to speed up your program is to forget micro-optimization and concentrate in better algorithms and caching data if possible.

  • Which iPad is better, the 2nd generation or the 3rd?

    I am trying to figure out which ipad is better because I know i want a white 16GB Wi-Fi only ipad.

    What about the iPad 4? It's much faster than the iPad 3.
    iPad 2 vs iPad 3 vs iPad 4: Which Is the Best Buy?
    http://ipad.about.com/od/Tablet_Computers_eReaders/a/iPad-2-Vs-iPad-3-Which-Is-T he-Better-Buy.htm
    http://www.techradar.com/news/mobile-computing/tablets/ipad-4-more-than-twice-as -fast-as-ipad-3-benchmarks-reveal-1108743
    http://www.digitaltrends.com/mobile/ipad-3-vs-ipad-4/
     Cheers, Tom

  • Which method can get the computer  screen photograph

    besides the createscreencapture method of robot class,which method have the
    function of grabing computer screen photograph.thank you.

    Do you know and this is some sort of competition to name the other method and class? Or do you not know - in which case: why don't you want to use createScreenCapture()?
    [Edit] I don't think there is a way that doesn't involve the Robot class.

  • Which method is better

    hi,
    when uploading data into sap,which method is to be used,either session method r call transaction method? how i can analyse which method is useful? explain briefly abt analying data?

    Hi,
    Better to use session method than other methods

  • Which method to count the number of character in a string?

    Hi all,
    I want to know which class and method to count the number of character in a string?
    Gary

    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html

  • Which macbook and better, the macbook pro or macbook air?

    What is the best macbook ?

    I really like the MacBook Air, but the Pro may be better for your needs. Larger screen size is an option, it has more ports, etc.

  • Which iMac is better, the ME086LL/A or MD093LL/A?

    These models appear to be exactly alike except the newer one (ME086LL/A) has the Intel Iris Pro graphics processor and the the older one (MD093LL/A)  has the NVIDIA GeForce GT 640M graphics processor. Is the Intel Iris better in any respect than the NVIDIA? Thanks.

    NVIDIA GeForce GT 640M uses what is called CUDA. CUDA uses the graphic card to speed up graphics and video rendering... for example... Photoshop, Final Cut Pro X (I think) and 3d software like Blender. This can speed up rendering time by 4 times or more.
    Intel Iris doesn't support CUDA.
    I would go with the NVIDIA GeForce GT 640M card.

  • Which iphone is better the 5s or the 5c

    which iphone would you choose
    the 5s or the 5c

    The differences in specs, price and performance are all on your online Apple Store site. Which model anybody here would choose doesn't matter. Decide what you want and what you can afford.

  • Which one is better, the Zen, the Zune, or the iPod?

    My boyfriend's birthday is Saturday and I was thinking about getting him one of the following. He had an iPod in the past but it broke in his pocket. I was thinking something like a Zen or a Zune but everything I have found on the internet leans towards the iPod. Any suggestions?

    The new touch screen Zune is looking pretty nice!
    Adam
    Best Buy Community - Retail, Americas
    Forum Guidelines | Terms & Conditions | Community Guidelines | Blogging Guidelines
    *Remember to mark your questions solved and click the star under the user's name to show your thanks!

  • Which is a better performer, the macbook air or the mac mini?

    Which one performs better, the late 2013 macbook air (standard configuration: 4GB RAM, dual core i5 1,3 Ghz CPU) or the mac mini core quad core i7, 4GB RAM with a regular hard disc?

    LowLuster 
    No Air model can be as fast as a Mini with a quad core i7 CPU. Can't happen.
    I didnt solicit your opinion, and it IS a fact, .....skilled users here on this board will and DO TELL other users OFTEN that:
    "outside of processor core use (video/ photo etc.) you will NOT NOTICE ANY DIFFERENCE on X computer vs. slower Y computer"
    I have a 8 month old QUAD core Mac Mini and it is , as I said above "noticeably not ONE BIT" faster than my current 2013 macbook Air with 8gig.
    My quad core came with 4gig of RAM as I recall, I immediately tossed in 16gig.
    Notice the word "noticeably"
    Your subjective hyperbole aside, you are wrong......., those above yourself and myself (point wise,...as Ogel has stated, Clinton has stated, and others) state this fact very often regarding ---"outside of processor core use (video/ photo etc.) you will NOT NOTICE ANY DIFFERENCE on X computer vs. slower Y computer"
    Its not my opinion, its a fact, namely additionally that I stated "noticeably"   - "my quad core mac mini on MOST EVERYTHING (which is most things since 'most things' are NOT photo and video editing) is not "noticeably" ONE BIT faster than my Macbook Air.
    "most things" people do (most people) on their computer does NOT involve photo and video editing (photoshop pro, final cut pro etc etc)
    This is a fact, that AS SUCH most people WILL NOT notice any difference in general computer use between a quad core mac mini (for example) and a entry level macbook Air. (SSD vs. HD speeds aside).       Nobody is going to notice faster youtube, or Word use, or websurfing, Acrobat Pro, Quicktime play, general APPS that havent changed much in 7 years.
    Dont curse on these family boards please, its uncouth.
    Peace

  • Which is best method to improve the performance

    Hi,
    I have one scnerio, to meet this requirement i have two methods
    My requirement is to get the data from multiple tables, so i am developing a query based on joins and this query may give approx 80000 rows.
    To meet this requirement i have two methods.
    I have confusion which is the best method to improve the performance.
    Method #1
    for i in <query>
    loop
    end loop;
    Here we are retriving row by row(80000 rows) from data base and applying our logic
    Method #2
    By using the BULKCOLLECT at a time we are getting all the rows(80000 rows) into plsql table.
    then loop is based on plsql table
    for i in 1..plsqltable.count
    loop
    end loop;
    Here we are retriving row by row(80000 rows) from plsql table instead of going to data base.
    Can any body please suggest which is the best to improve the performance

    Using BULK COLLECT will give you better performance with a large data set because there will be reduced IO with this method versus the traditional CURSOR FOR LOOP. Database Admin's (DBAs) typically don't like BULK COLLECT because developers tend to forget to limit the number of rows returned by the BULK COLLECT operation so it could use up too much memory. Take a look at DEVELOPER: PL/SQL Practices On BULK COLLECT By Steven Feuerstein for some great tips on using BULK COLLECT. Another good Feuerstein article is: Bulk Processing with BULK COLLECT and FORALL.
    As others have mentioned, you should have posted your question in the PL/SQL forum. ;)
    Hope this helps,
    Craig...

Maybe you are looking for

  • Performing a Sum on a Conditional if statement (in Business Objects)

    Post Author: Rhonda Jackson CA Forum: Formula I have been trying to debug a sum statement that evaluates a code (for example 0001) which then maps the corresponding dollar amount to a new column.  This part is working.  Unfortunately when I try to su

  • Shipment Cost Estimation Report

    Hi Experts, There is an existing report which is very helpful regarding most transportation details. You can pull information at the delivery or item level of all types of shipments in one place. We use this to review what shipments we need to proces

  • Album art not being displayed when I play music!

    I input the album art into my library and the ipod and when I "get info" it will display the artwork but not when I play the songs on the ipod! What am I doing wrong? PC   Windows XP  

  • Rename Technical names

    Hello people, I would rename technical names of infosources, datasources... I see 2 ways : - rename in a table the technical name of this infoobjects - copy the infosource, with template the infosource to change. In the first one, i don't know if thi

  • Java Card and PKCS#11 or MS CSP

    Does anybody have any idea how Java Card could be integrated in an standard e-mail signing application, i.e. with Outlook, S/Mime, MS CSP and PC/SC or Netscape with PKCS#11 and PC/SC? My understanding is that with standard ISO Cards the connection e-