INSERT in PLSQL loop  in Oracle 9i  scheduled job has poor performance

Hi,
I have a scheduled job running in Oracle 9i. But everytime it executes the following piece of code, the INSERT process slows down drastically.
-------------------------------typical piece of code having problem-----------------------------------
LOOP
FOR increbkgs IN bookings_cur (in_chr_fiscal_period_id,
allrec.cust_name_string
LOOP
l_num_rec_count := l_num_rec_count + 1;
INSERT INTO SA_PORTAL_CDW_BOOKINGS_INCTEMP
(product_id, territory_code,
global_target_id, service_type,
equipment_deployment, created_date, updated_date,
fiscal_period_id, customer_id,
ship_to_country,
bookings_amount, sams_alliance_id
VALUES (increbkgs.product_id, increbkgs.territory_code,
increbkgs.global_target_id, increbkgs.service_type,
increbkgs.equipment_deployment, SYSDATE, SYSDATE,
increbkgs.fiscal_period_id, increbkgs.customer_id,
increbkgs.ship_to_country,
increbkgs.bookings_amount, allrec.sams_alliance_id
IF (l_num_rec_count = 500)
THEN
l_num_rec_count := 0;
COMMIT;
END IF;
END LOOP;
END LOOP;
All the tablespaces are auto-extend. But we have still tried to increase the tablespace manually from 2% to 30% by adding datafiles. Still the INSERT is slowing down for some reason.
(The same process in Oracle 8i is much faster)
Any hint or guidance is greatly appreciated.
Thanks and regards,
Ambili

commits in loops are great for slowing down things. Actually commits in loops are just about the best way of stalling any 'process' in Oracle.
A much better way is to resize your undo tablespace to permit one single commit at the end of the whole thing. Yes it could be big, but that's the way Oracle works.
If you want more info about this, buy Thomas Kyte's book found at http://apress.com/book/bookDisplay.html?bID=10008

Similar Messages

  • Enable Oracle dbms scheduled jobs

    Hi Gurus,
    I need to enable a set of dbms jobs which got transferred as a result of exporting a 9i database and importing to 11g database.
    They were running as scheduled jobs in old legacy database.
    I can see them in SQL Developer under DBMS jobs but don't know how to enable them
    Please help. My current Oracle version is 11g.
    Thanks
    Amitava.

    amitavachatterjee1975 wrote:
    Hi Gurus,
    I need to enable a set of dbms jobs which got transferred as a result of exporting a 9i database and importing to 11g database.
    They were running as scheduled jobs in old legacy database.
    I can see them in SQL Developer under DBMS jobs but don't know how to enable them
    Please help. My current Oracle version is 11g.
    Thanks
    Amitava.
    post SQL & results which show any of the jobs actually got transferred.
    post SQL & results that show they are not scheduled or running now.

  • Oracle Grid Scheduled jobs disappear from active tab?

    Thread was posted before as a similar situation.
    Grid Control jobs disappeared from schedule
    But was never answered;
    For Grid control v10.2.0.3 Unix box.
    I was wondering if this is a bug within OGC. Some of the scheduled jobs disappear from the active tab and have to be re-submitted. Does anyone or has anyone experienced this? Agents are in synch, and the only thing that was done was a bounce of the database and possibly the box itself.
    Thanks,
    Mark S.

    Hi,
    I have upgraded Discoverer 4i EUL to 10g EUL by using auto upgrade utility which comes with the Disocverer 10.1.2 and installed the Discoverer 10g Admin Edition on my PC. And I executed the batchusr_app.sql and assigned a user DISCREP(other than APPS). We are in APPS mode EUL. The script execution completed fine and the EUL5 packages were created under the DISCREP owner. When I log into the Discoverer Admin and select Tools/Privileges and at the point of assigning the result tables to a schema which is DISCREP, I am getting a message saying that 'EUL5_BATCH_REPOSITORY' package is wrong version and batchusr.sql script needs to be run. I ran the batchusr.sql script and when tried to assign the schema to own result tables it gave me the same message.
    Any ideas. You may have gone through this during your upgrades or installation.
    Thanks,
    Sabbani

  • Schedule job has been deleted

    Dear Guru,
    Today morning when I see my Test server there was a standard job which was running in every server it has been deleted,
    Now when I check through SM37 T-code there no more  SAP standard job is there.
    Request you to suggest me how can again I can set all SAP standard jog on that client.
    Regards,
    Bipin.

    Hello Bipin
    Go to SM36,click on Standard jobs,it will ask for default scheduling,click on yes and it will schedule all the SAP standard jobs
    Rohit

  • Oracle.ias.scheduler

    http://download-west.oracle.com/otn_hosted_doc/ias/preview/web.1013/b16026/overview-summary.html
    I am trying to find out in which jar file can i find the package oracle.ias.scheduler.
    Please help
    Thanks
    AS

    I need this Jar to try out few examples and to schedule jobs.
    I am not able to import oracle.ias.scheduler* as i don't know which jar path is to be added in the classpath
    http://www.oracle.com/technology/tech/java/oc4j/1003/how_to/jobscheduler/scheduler-userguide.html
    see listing 1.
    import java.io.File;
    import java.io.IOException;
    import oracle.ias.scheduler.Job;
    import oracle.ias.scheduler.Executable;
    import oracle.ias.scheduler.JobContext;
    import oracle.ias.scheduler.JobExecutionException;
    public class BackupJob implements Executable {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Why does SCHDNEGACTION scheduler job have high CPU usage?

    Hi,
    In my embeded device(double CPU 1.5 G HZ ) SCHDNEGACTION scheduler job has 90% CPU usage. Why does the scheduler job have so high CPU usage? What is the job doing for?

    Hi,
    This job is not created by the scheduler. You will have to find out what component creates the job and what exactly it does to figure out why it is using high cpu and what would be the effects of disabling it (which would prevent it from running).
    Hope this helps,
    Ravi.

  • Scheduled Job to gather stats for multiple tables - Oracle 11.2.0.1.0

    Hi,
    My Oracle DB Version is:
    BANNER Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    In our application, we have users uploading files resulting in insert of records into a table. file could contain records ranging from 10000 to 1 million records.
    I have written a procedure to bulk insert these records into this table using limit clause. After the insert, i noticed my queries run slow against these tables if huge files are uploaded simultaneously. After gathering stats, the cost reduces and the queries executed faster.
    We have 2 such tables which grow based on user file uploads. I would like to schedule a job to gather stats during a non peak hour apart from the nightly automated oracle job for these two tables.
    Is there a better way to do this?
    I plan to execute the below procedure as a scheduled job using DBMS_SCHEDULER.
    --Procedure
    create or replace
    PROCEDURE p_manual_gather_table_stats AS
    TYPE ttab
    IS
        TABLE OF VARCHAR2(30) INDEX BY PLS_INTEGER;
        ltab ttab;
    BEGIN
        ltab(1) := 'TAB1';
        ltab(2) := 'TAB2';
        FOR i IN ltab.first .. ltab.last
        LOOP
            dbms_stats.gather_table_stats(ownname => USER, tabname => ltab(i) , estimate_percent => dbms_stats.auto_sample_size,
            method_opt => 'for all indexed columns size auto', degree =>
            dbms_stats.auto_degree ,CASCADE => TRUE );
        END LOOP;
    END p_manual_gather_table_stats;
    --Scheduled Job
    BEGIN
        -- Job defined entirely by the CREATE JOB procedure.
        DBMS_SCHEDULER.create_job ( job_name => 'MANUAL_GATHER_TABLE_STATS',
        job_type => 'PLSQL_BLOCK',
        job_action => 'BEGIN p_manual_gather_table_stats; END;',
        start_date => SYSTIMESTAMP,
        repeat_interval => 'FREQ=DAILY; BYHOUR=12;BYMINUTE=45;BYSECOND=0',
        end_date => NULL,
        enabled => TRUE,
        comments => 'Job to manually gather stats for tables: TAB1,TAB2. Runs at 12:45 Daily.');
    END;Thanks,
    Somiya

    The question was, is there a better way, and you partly answered it.
    Somiya, you have to be sure the queries have appropriate statistics when the queries are being run. In addition, if the queries are being run while data is being loaded, that is going to slow things down regardless, for several possible reasons, such as resource contention, inappropriate statistics, and having to maintain a read consistent view for each query.
    The default collection job decides for each table based on changes it perceives in the data. You probably don't want the default collection job to deal with those tables. You probably do want to do what Dan suggested with the statistics. But it's hard to tell from your description. Is the data volume and distribution volatile? You surely want representative statistics available when each query is started. You may want to use all the plan stability features available to tell the optimizer to do the right thing (see for example http://jonathanlewis.wordpress.com/2011/01/12/fake-baselines/ ). You may want to just give up and use dynamic sampling, I don't know, entire books, blogs and papers have been written on the subject. It's sufficiently advanced technology to appear as magic.

  • Interface Build for Oracle Workforce Scheduling (OWS)

    Hi there
    I am working with OWS which is a product so new that I see no Metalink Notes (apart from the product documentation) nor any posts on this forum.
    Am particularly interested in developing an interface to it.
    The most useful document for this is
    Oracle Workforce Scheduling Integration Functional Guide 5.0.2
    462087.1 12-OCT-2007 Oracle Workforce Scheduling Generic REFERENCE
    Within this document, there is a tantalising reference to this document:
    Oracle Workforce Scheduling
    Interface Development Kit Guide
    https://metalink.oracle.com/metalink/plsql/ml2_documents.sh
    owDocument?p_database_id=NOT&p_id=390822.1
    Whislt I can find the Integration Functional Guide on Metalink, there seems to be no documentation anywhere on this IDK.
    Can anyone help me track down this missing link in the OWS documentation?

    Hi,
    Has anyone worked on Oracle Workforce Scheduling (OWS) product? I am adding this question here as I could see some pointers mentioned about it here.
    If anyone has worked on Oracle Workforce Scheduling (OWS) for scheduling requirements along with Demantra and OTL , please share the experience and pro’s and con’s of this product.
    Also, if you can provide the details about the fitment of this product to handle workforce scheduling related functionalities e.g. what OWS can handle and what OWS cannot handle, that will be of great help.
    Thanks,
    Parag

  • How to stop a Scheduler Job in Oracle BI Publisher 10g

    Hello!
    Can someone tell me how can I stop a scheduler job in Oracle BI Publisher 10g?
    I scheduled a bursting job to run a report but is running during two days.
    I would like to stop it.
    Thanks.
    Edited by: SFONS on 19-Jan-2012 07:16

    Unfortunately there is no way to stop a job once it is being executed. Yes as you read, it is not possible once job has started.
    Same thing applies for running queries.
    Once queries are sent to the DB BIP loses control over them. The message you see (if any) "Click Here to Cancel" does not stop any query
    it is just a message.
    I guess you will have to stop/kill the process in your DB
    regards
    Jorge
    p.s If you consider your question answered then please mark my answer as *"Correct"* or *"Helpful"*

  • How to insert an image file in Oracle database

    hi
    can you please tell me how to insert an image file into oracle database????
    suppose there is one image file in c:\pictures\rose.jpg. how to insert that file into database? theoretically i know that will be BFILE type but i dont know how to insert that.
    will be waiting for your reply........
    thanks & regards,
    Priyatosh

    Hello,
    The easiest way to load a blob is to use SQL loader.
    This example comes from the utilities guide:
    LOAD DATA
    INFILE 'sample.dat'
    INTO TABLE person_table
    FIELDS TERMINATED BY ','
    (name CHAR(20),
    1 ext_fname FILLER CHAR(40),
    2 "RESUME" LOBFILE(ext_fname) TERMINATED BY EOF)
    Datafile (sample.dat)
    Johny Quest,jqresume.txt,
    Speed Racer,'/private/sracer/srresume.txt',
    Secondary Datafile (jqresume.txt)
    Johny Quest
    500 Oracle Parkway
    Secondary Datafile (srresume.txt)
    Loading LOBs
    10-18 Oracle Database Utilities
    Speed Racer
    400 Oracle Parkway
    regards,
    Ivo

  • How to insert a image file into oracle database

    hi all
    can anyone guide me how to insert a image file into oracle database now
    i have created table using
    create table imagestore(image blob);
    but when inserting i totally lost don't know what to do how to write query to insert image file

    Hi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
    Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
    out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
    out.println("   <input type='submit' name='submit' value='Submit' class='smalltext'>");
    out.println("</form>"); Import this once you have the jar file:
    import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
    private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
            boolean result = true;
            String fileName = null;
            byte fileData[] = null;
            String fileUploadError = null;
            String imageType = "";
            String error = "";
            DiskFileUpload fb = new DiskFileUpload();
            List fileItems = fb.parseRequest(request);
            Iterator it = fileItems.iterator();
            while(it.hasNext()){
                FileItem fileItem = (FileItem)it.next();
                if (!fileItem.isFormField()) {
                    fileName = fileItem.getName();
                    fileData = fileItem.get();
                    // Get the imageType from the filename extension
                    if (fileName != null) {
                        int dotPos = fileName.indexOf('.');
                        if (dotPos >= 0 && dotPos != fileName.length()-1) {
                            imageType = fileName.substring(dotPos+1).toLowerCase();
                            if (imageType.equals("jpg")) {
                                imageType = "jpeg";
            String filePath = request.getParameter("FILE_PATH");
            session.setAttribute("filePath", filePath);
            session.setAttribute("fileData", fileData);
            session.setAttribute("fileName", fileName);
            session.setAttribute("imageType", imageType);
            return result;  
         } And now finally the method to actually write the file to the database:
    private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
            //If the previous code found a file that can be uploaded then
            //save it into the database via a pstmt
            String sql = "";
            UtilDBquery udbq = getUser(request).connectToDatabase();
            Connection con = null;
            int signatureID = 0;
            PreparedStatement pstmt = null;
            try {
                udbq.setUsePreparedStatements(true);
                con = udbq.getPooledConnection();
                con.setAutoCommit(false);
                if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
                    sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
                    pstmt = con.prepareStatement(sql);
                    ResultSet rs = pstmt.executeQuery();
                    while(rs.next()) {
                       signatureID = rs.getInt(1);
                    if (fileName != null && imageType != null) {
                        sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setInt(1, signatureID);
                        pstmt.setBinaryStream(2, is2, (int)(fileData.length));
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
                if(mode.equals("U") && signatureIDIn != 0) {
                    signatureID = signatureIDIn.intValue();
                    if (fileName != null && imageType != null) {
                        sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setBinaryStream(1, is2, (int)(fileData.length));
                        pstmt.setInt(2, signatureID);
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
            } catch (Exception e) {
                con = null;
                throw new Exception(e.toString());
            return signatureID;
       }

  • How to create SSWA plsql function in Oracle Apps of HTML call .html

    Hello Team,
    I am working on Oracle Apps 11i (11.5.10.2)
    I want to know , what is the process to create a , "SSWA plsql function" in Oracle Apps of type "HTML" and html call tab.
    How to create that Function and how to attach the PL/SQL code to these functions.
    How it works.
    Please help me to understand this concept from basics.
    Kind Regards

    Hi;
    Please review:
    how to setup a forms function in R12 to launch an URL?
    http://www.trutek.com/serendipity/index.php?/archives/15-An-Example-of-How-to-Create-Custom-Functions,-Menus,-and-Responsibilities.html
    Regard
    Helios

  • Inserting a record in an Oracle database

    Hi,
    I would appreciate if anyone could provide a code snippet showing how to insert a record into an Oracle 9i database. The columns in the database table have datatypes such as NUMBR, VACHAR2, and DATE. Some of the columns may be null. The input text is in the form of String. The string from the date fields is in the form 'YYYY-MM-DD HH:MI:SS PM' and I have converted these to java.sql.Date objects. How do I deal with nulls?
    Thanks.

    I am having a problem inserting a date field. The input string is in the form YYYY-MM-DD HH:MM PM. I converted the input string to a java.sql.Date object before trying to post the record. However, an example of what gets inserted is: '2001-12-04 12:00 AM' even if the input date string is: "2001-12-04 04:40". In other words, the hour and minute portions do not get inserted correctly.
    Why is this and how can I resovle this? My code is as follows: (try/catch blocks are not shown)
    String m_HireDate = "2001-12-04 04:40 PM"; // Input string.
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
    java.utilDate m_UtilDate = sdf.parse(URLDecoder.decode(m_HireDate);
    java.sql.Date m_SQLDate = new java.sql.Date(m_UtilDate);
    Connection con = DriverManager.getConnection(url,"abc"," abc") ;
    Statement stmt =
    con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_UPDATABLE) ;
    String sqlselect = "SELECT EMP_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, HIRE_DATE, FROM EMP" ;
    ResultSet rs = stmt.executeQuery(sqlselect) ;
    // EMP_ID is the primary key. It has a datatype of NUMBER in the database tabe
    int EMP_ID1 = Integer.parseInt(EMP_ID);
    rs.moveToInsertRow() ;
    rs.updateInt("EMP_ID", EMP_ID1) ;
    rs.updateString("FIRST_NAME", "John" );
    rs.updateString("MIDDLE_NAME", "M" );
    rs.updateString("LAST_NAME", "Smith");
    rs.updateDate("HIRE_DATE" , m_SQLDate); //m_SQLDate is a java.sql.Date object
    rs.insertRow() ;
    Now get the inserted value from SQLPLUS:
    SELECT TO_CHAR(HIRE_DATE, 'YYYY-MM-DD HH:MI PM') FROM EMP WHERE EMP_ID =EMP_ID1;
    The output is: "2001-12-04 12:00 AM"
    Thanks.

  • Use java thread? or Oracle DB scheduler?

    I have a java thread which purge records in a table every 30 seconds. The thread calls a prepared statement which is like "delete from MyTable where status=99"
    can I use DB's scheduled job to do the same thing? I can create a DB schedule, and a job in plsql.
    Thus I can save on DB connections.
    Which one is better in terms of performance?

    SoulTech2012 wrote:
    i personally recommend against PL/SQL if you can manage it
    some will argue that it's okay to couple yourself to a database because you're likely not to change it
    but i've seen enough migrations to know the painConversely I have seen attempts to process data by dragging it across the network in the vain attempt to make the application database agnostic. Which results in orders of magnitude more processing time when the application needs to do anything approaching real volume.

  • In which  join condition case, it will go to infiniti loop , in Oracle data

    Hi Experts,
    Can any one please tell me , in which join condition case, it will go to infiniti loop , in Oracle database.
    Thanks&Regards,
    Sanjeev.

    user13483989 wrote:
    Hi Experts,
    Can any one please tell me , in which join condition case, it will go to infiniti loop , in Oracle database.
    Thanks&Regards,
    Sanjeev.with faulty data
    Handle:     user13483989
    Status Level:     Newbie (15)
    Registered:     Jan 16, 2011
    Total Posts:     192
    Total Questions:     87 (73 unresolved)
    why so many unanswered questions?

Maybe you are looking for