Performance comparison between using sql and pl/sql for same purpose

Hi All,
I have to do some huge inserts into a table from some other tables. I have 2 option:
Option 1
======
a. Declare a cusor for a query involving all source tables, this will return the data to be populated into target
b. Use a cursor for loop to loop through all the records in the cursor
c. for each iteration of the loop, populate target columns, do any calculations/function calls required to populate derived columns, and then insert the resulting record into target table
Option 2
======
Just write a big single "Insert Into ..... Select ..." statement, doing alll calculations/funtion calls in the select statement generating the source data.
Now my question is ; which option is fast? and why. This operation is performace critical so I need the option which will run faster. Can anybody help???
Thanks in Advance.

user9314072 wrote:
while the above comments are vaild, you should concider maintainability in you code. Even if you can write the sql it might be the code becomes complex making tuning very dificult, and derade performance.Beg to differ on that. Regardless of complexity of code, SQL is always faster than PL/SQL when dealing with SQL data. The reason for that is that PL/SQL still needs to use SQL anyway for row retrieval, and in addition it needs to copy row data from the buffer cache into the PL/SQL PGA. This is an overhead that does not exist in SQL.
So if you are processing a 100 million rows with a complex 100 line SQL statement, versus a 100 million rows 100 line PL/SQL procedure, SQL will always be faster.
It is a trade off, my experiance is large SQL's 100's lines long become hard to manage. You need to ask yourself why there are 100's of line of SQL. This points to an underlying problem. A flaky data model is very likely the cause. Or not using SQL correctly. Many times a 100 line SQL can be changed to a 10 liner by introducing different logic that solves the exact same problem easier and faster (e.g. using analytical SQL, thinking "+out-of-the-box+").
Also, 100's of line of SQL points to a performance issue always. And it does not matter where you move this code logic to PL/SQL or Java or elsewhere, the performance problem will remain. Moving the problem from SQL to PL/SQL or Java does not reduce the number of rows to process, or make a significant change in the number of CPU instructions to be executed. And there's the above overhead mentioned - pulling SQL data into a client memory segment for processing (an overhead that does not exist using SQL).
So how do you address this then? Assuming the data model is correct, then there are 2 primary methods to address the 100's of SQL lines and its associated performance problem.
Modularise the SQL. Make the 100's of lines easier to maintain and understand. This can be done using VIEWS and the SQL WITH clause.
As for the associated performance issue - materialised views comes to mind as an excellent method to address this type of problem.
my advice is keep things simple, because soon or later you will need to change the code.I'm all for that - but introducing more moving parts like PL/SQL or Java and ref cursors and bulk fetching and so on.. how does that reduce complexity?
SQL is the first and best place to solve row crunching problems. Do not be fooled into thinking that you can achieve that same performance using PL/SQL or Java.

Similar Messages

  • Looking for Performance Comparisons Between JRockit 6 and Sun Java SE 6

    Hello,
    Can someone point me to some performance comparisons (benchmarks, etc.) between the JRockit and Sun JVMs?
    Thanks in advance.

    Hi Ben.
    Before I send to to the SPEC sites (which can be a tad hard to parse) I must ask - What application or type of application are you interested in? The answer will vary a bit depending on what you need.

  • What is the speed/performance comparison between Soundbooth CS5 and Audition CS6?

    Obviously, I don't need to be convinced about the difference. However, in demonstrating and working with Audition I didn't take a note of these speed differences. Does anyone have this information for business justification reasons?
    I am looking for the speed of a sound file (*.wav, approximately 1-5minutes in length) rendering in Soundbooth CS5 and Audition CS6 as well as a comparison of doing 10 files (approximately 1-5 minutes in length each) in Soundbooth and in Audition CS6 (using batch processing) to *.mp3 with basic processes applied. Basic processes that I am checking are Noise Reduction, Trimming front and end silences, Normalization, and rendering to *.mp3 (from *.wav). If anyone can do this for me, that would be awesome!!

    travis_smith_ wrote:
    Hello _durin_, yes all those are great arguments that I've already included; however, some people like to use accurate measures/times/processes...they want numbers.
    So, do you (or anyone else) happen to know the render engine speed of 1 file in Soundbooth v. 1 file in Audition?
    What Durin hasn't perhaps made quite clear is that you'd have to do this on just one machine to come up with any comparisons at all - and if that machine isn't identical to yours, then it's going to be meaningless anyway; some of the processes (like NR) will vary considerably between two different machines, even running the same software. There is no way on earth that this would be an accurate comparison, and I don't think it would convince anybody who actually understood what was at issue. This is the politest way of saying that it's not going to happen... and if Durin, as Audition's Product Owner, isn't prepared to commit himself, then nobody's going to.... BUT:
    Now I am moving towards the argumentation that it should replace everyone's Soundbooth, which is why I need the justification. I would run the tests myself over the current set of files, but with the license gone, I cannot.
    Your real justification isn't going to be based on anything like dodgy process measurements at all, but this: Soundbooth is discontinued - there's very little, if any, support for it now, and there will be no updates to cope with OS changes, etc. Audition, on the other hand, is a long-term, well-supported software product that's under active development, and this is clearly intended to continue. Also there are business package deals to be done (like active subscriptions, etc) that simply weren't available to Soundbooth users, which companies can use far more flexibly. I think you'll find that arguements like this will cut far more mustard than any odious comparisons of 'speed' will.

  • Can we use actual and plan data for same cube?

    hi friends,
    can we use actual data and plan data in same cube in bps.
    Thanking u
    suneel.

    Hi,
    Let us take std cube 0SD_C03 where we store billing info,sales order info and delivery info. But still in reporting we can get values without any mismatch in their respective KF. It is possible because of a cahracterstic called Documnet category which gets values in update rule by constant .
    Similarly we can have 2 types of data (plan and actual) in a single cube by having different value for a characterstic. Most frequently used characterstics for this are 0VERSION and Value type.
    With rgds,
    Anil Kumar Sharma .P

  • Performance comparison between oops reports and normaal reports

    Hi Abapers,
                      Can anyone tell me that how is it better to use oops reports instesad of normal reports
    as there is no difference in select query in both the reports, and if you have any reports which give the same output developed in oops and normal way....
    pls provide me with that.... so that i can check....
    Regards
    Aarif

    Hi Arif,
    the performance tuning doesn't mean concern of data fetch load or reducing database access. It also means reduce ABAP load i.e. load of Application Server.
    OOABAP report works directly with memory. not with work area or tempory variable top store a value. So if your program is reached with READ, LOOP...ENDLOOP etc. you can reduce its load by using OOABAP concept.
    Getting this think, you can develope an application of your own.
    Regards,
    Anirban

  • Questions on the comparison between Oracle Forms and Oracle APEX

    Hi All,
    The link below presents information about Oracle Application Express for Oracle Forms Developers, the table at the end of the page shows a comparison between Oracle Forms and Oracle APEX, all the points of comparisons are clear for me except 3 points which are:
    •Locking, what is meant by locking models?
    •Database Connections, what is meant by Synchronous/Asynchronous connections in Oracle Forms and Oracle Apex?
    •Architecture, what is meant by 2tier and 3 tier connections?
    http://www.oracle.com/technology/products/database/application_express/html/apex_for_forms.html
    What I need is a simple explanation for these points without deep details.
    Thanks

    Hi
    That is how I understand that document:
    Locking: Forms, by default, locks a row as soon as the user starts modifying the data. That is pessimistic locking. Apex, on other hand (and optionally forms also) do not lock the record, but before applying any changes checks if the data has changed since the user queried it (what for some reason is called optimistic "locking")
    DB connections: I am not sure why they used the terms synchronous/asynchronous, but the difference is that Forms, by default, keeps an permanent DB connection while the user is using the application, while Apex gets a connection from a connection pool every time a page is requested/submitted.
    Architecture: Forms (in its web version at least) has 3 tiers: the browser, the appserver where the forms service runs and the database. As Apex runs inside the database, there are only 2 tiers: the browser and the database (though you still may need an http server in between which serves static content, I don't think it is considered part of the application in this context). If you are talking about client/server forms, then there are only 2 tiers.
    I hope this helps!
    Luis

  • Comparison between Oracle Contracts and Oracle Procurement Contracts?

    Hi All,
    I need some document which give the Comparison between Oracle Contracts and Oracle Procurement Contracts?
    And which of them are suitable for what type of contracts?
    Thanks
    Syed

    Hi,
    Any kind of help plz.
    Regards,
    Subhra

  • Comparison Between Oracle eBS and JD Edwards

    Hi All,
    Is there any site / document / any kind of referference / help on comparison between Oracle-eBS and JD Edwards mainly for Finance and SCM module please ? Need this urgently so any help is appreciated.
    Thanks & Regards,
    Subhra Saha

    Hi,
    Any kind of help plz.
    Regards,
    Subhra

  • I used an ethernet cable between my iMac and Time Capsule for the initial backup.  Now that initial backup is concluded, can I simply unplug the Time Capsule from my computer?

    I used an ethernet cable between my iMac and Time Capsule for the initial backup.  Now that initial backup is concluded, can I assume I can simply unplug the Time Capsule from my computer without any glitches and Time Capsule will then run wirelessly.  Is this assumption correct? 

    can I assume I can simply unplug the Time Capsule from my computer without any glitches and Time Capsule will then run wirelessly.  Is this assumption correct?
    Yes, if the computer will be able to receive a strong wireless signal from the Time Capsule.
    I did not disable wireless.  So I assume the backups are occurring both with the ethernet and wirelessly.
    It is inot possible to have both an "active" Ethernet and "active" wireless signal simultaneously. If an Ethernet connection is established, your computer will default to the Ethernet connection. If the Ethernet cable is unplugged, the computer will revert to the wireless connection.
    I also show 2 wireless networks available through Airport.  Shouldn't there only be one now?
    You have a simultaneous dual band Time Capsule. That means that it will always be providing both a 2.4 GHz and a 5 GHz network.
    I named my new network the same name as the old network.  This enabled all of our devices to continue with their connection without entering the new network and/or passwords; however, I am afraid this may pose problems in the future somehow.  Any input on this issue as well?
    Things should be fine. Devices will connect to the best signal.....either 2.4 GHz or 5 GHz....based on their capabilties and location in relation to the Time Capsule.

  • Difference between using Binding and Value Attribute

    what is the deference between using binding and value attribute, when I use binding attribute at the time of Value change listener is behaving like action listener,
    Ex:
    If I use value attribute, at the time of value change listener the component is not showing the result in the component but when I use Binding attribute it is happening automatically. So I want to know how the binding attribute is working.
    I know, at the time of binding attribute the component is creating an instance at the bean side, So even also how it is following the life cycle of the JSF Frame work, and also Please suggest me weather which one is better to use either Binding or Value?

    JNaveen wrote:
    If I use value attribute, at the time of value change listener the component is not showing the result in the component but when I use Binding attribute it is happening automatically. So I want to know how the binding attribute is working.You need to learn about the JSF lifecycle. The ValueChangeEvent is invoked after conversion and validation in the 3rd phase, while the model values are updated in the 4th phase. In the valueChangeListener method you normally use ValueChangeEvent#getNewValue() to get the new value after the change.
    I know, at the time of binding attribute the component is creating an instance at the bean side, So even also how it is following the life cycle of the JSF Frame work, and also Please suggest me weather which one is better to use either Binding or Value?Use the 'value' attribute to bind the value to the bean. Use the 'binding' attribute to bind the component to the bean. If you don't need to precreate the component or do other things than getting/setting its value, then there is no need for the 'binding' attribute.
    Read on those links if you want to know something more about the JSF lifecycle:
    [http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html].
    [http://jcp.org/aboutJava/communityprocess/final/jsr252/index.html] (pick 1st download).

  • Difference between using Java and Non-Java in Webi.

    Hi ,
    I have one more question requesting for an answer.
    Would like to know what is the Difference between using Java and Non-Java in Webi.
    Thank You in advance.
    Appana Ganesh.

    Hi,
    check the Information in following post, the differences are discussed there:
    http://scn.sap.com/thread/3295306
    best regards,
    Victor

  • Use AO and AI in the same program

    Hello,
    I like write a program to use AO and AI in the same program.
    In this program write a timer a voltage to a AO port and after then it should read a voltage.
    I know how I write voltage to a AO port and read a voltage on a AI port, but not in a the same program.
    The read- and the write-Task, should work as soon as possible (<=1ms). 
    (My timer have 100us ticks) 
    what should I inilize for the PCI6229 card, to use AO and AI and in which order?
    Can I have a example or pseudocode?
    Best regards
    Heiko Mayer 

    Hi Heiko-
    There is very little overlap between the AO and AI examples, so you should be able to piece the code together pretty easily.  I would offer these suggestions:
    1.  These lines should only be executed once, and they should be done before any AI or AO specific initialization is done:
    configureTimebase (board);
    pllReset (board);
    analogTriggerReset (board); 2.  It does not matter which order you perform the AI or AO initialization, but I would recommend waiting to unground the AO reference (by   board->AO_Calibration.writeAO_RefGround (kFalse) until all of the AI and AO init is done.  This will help to avoid any glitching on the AO lines.  The only steps that should be saved until after ungrounding the reference are the Start operations for AI and AO (depending on the AO mode you use, there may not be a specific Start operation to call.  Consult the MHDDK examples for more info about the required steps).
    Hopefully this helps-
    Tom W
    National Instruments

  • What's the difference between the LRU and NRU strategy for stateful session bean?

    Hi,
    Does anybody know the difference between the LRU and NRU strategy for
    stateful session bean?
    Thanks,
    Levi

    LRU makes the assumption that the bean that has been used a lot recently is
    likely to be used again.
    NRU simply removes the beans that have not been used for a stipulated amount
    of time.
    The algorithm for the LRU is much more complicated than the NRU. I think BEA
    recommends LRU for better performance and NRU when you have memory
    constraints.
    "levi" <[email protected]> wrote in message
    news:[email protected]..
    Hi,
    Does anybody know the difference between the LRU and NRU strategy for
    stateful session bean?
    Thanks,
    Levi

  • My Ipad mini does not see my printer. my wife's ipad2 does. We both use IOS8 and upgraded at the same time. How can I remedy this?

    My Ipad mini does not see my printer. my wife's ipad2 does. We both use IOS8 and upgraded at the same time. How can I remedy this?

    OK great info!
    I found 2 possible ethernet to USB adapters:
    By "Plugable":  USB 2.0 to ethernet LAN wired network adapter - seems this will work, but I'll contact Plugable.
    2. Apple USB Ethernet Adapter
    Easily connect your MacBook Air computer to an Ethernet network with the Apple USB Ethernet Adapter. Small and light, it connects to the USB 2.0 port of your MacBook Air and provides an RJ-45 connector that supports 10/100BASE-T performance.  BUT NOT SURE IF THIS WILL WORK ON ANYTHING BUT a MacBook Air…
    One person commented: 
    This little gem used to be the device of choice for adding a second Ethernet interface to a Mac Mini Server and I'd been using one that way for about a year. After doing a software update to 10.6.6 it stopped working. Forewarned is forearmed – it appears that Apple is finally enforcing the MacBook Air system requirement.
    Thanks for any additional comments.
    Best regards,
    Steve Schulte
    Sunday 6 January 2013

  • I am using a Palm Pilot still for several purposes, and the desktop version can run om my Mac OS X 10.6.8, but I cannot find a version that runs on OS X Mavericks, which prevents me from upgrading as my PalmPilot is storage for vital info.

    I am using a Palm Pilot still for several purposes, and the desktop version can run om my Mac OS X 10.6.8, but I cannot find a version thjat runs on OS X Mavericks, which prevents me from upgrading as my PalmPilot is storage for vital info. Any solution?

    Thank for for your suggestions. Unfortunately they are of little help. I am running on Snow Leopard and the PalmDesktop works fine. However, I do not want to quit my PalmTungsten unit as it is my backup for all my important access information. If it cannot run on Mavericks and no other solution is at hand, I simply will not update my OS X, but work on my Snow Leopard as it is.
    I do not know how on earth I can migrate the information from my Palm into another system, and then quit the PalmPilot. If you have any intelligent solutions to this I would appreciate an input. A manual copy and paste solution is not acceptable. I may however run it on Windows via Parallel Desktop, but it is a lousy solution, and demonstrates (again) the weakness of Apple's OS and lack of compatibility. I am not impressed by the OS X performance.
    Thank your for your attention.

Maybe you are looking for