SQL Statement cause delay on exceptional days to run

Hi ,
We are running the same sql statement on daily basis.
5 days a week, it gets completed in 10 mins and once or, twice in a week , it takes 7 – 10 Hrs to execute.
what are the tuning methods and steps we can apply to know the real culprits.
Regards
Asif

Before you dive into reading books and other stuff, you can simply look at the execution plan of your Statement on SQL*PLUS.
It's very easy, just do the following with your SQL Statement on both cases when it takes 10 minutes and hours and compare the results.
DEV@TEST>
DEV@TEST> SET AUTOTRACE TRACEONLY
DEV@TEST>
DEV@TEST> SET TIMING ON
DEV@TEST>
DEV@TEST> SELECT * FROM USER_OBJECTS;
105 rows selected.
Elapsed: 00:00:00.01
Execution Plan
   0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=146 Card=1620 Byte
          s=259200)
   1    0   VIEW OF 'USER_OBJECTS' (VIEW) (Cost=146 Card=1620 Bytes=25
          9200)
   2    1     UNION-ALL
   3    2       FILTER
   4    3         TABLE ACCESS (FULL) OF 'OBJ$' (TABLE) (Cost=146 Card
          =1731 Bytes=136749)
   5    3         TABLE ACCESS (BY INDEX ROWID) OF 'IND$' (CLUSTER) (C
          ost=2 Card=1 Bytes=8)
   6    5           INDEX (UNIQUE SCAN) OF 'I_IND1' (INDEX (UNIQUE)) (
          Cost=1 Card=1)
   7    2       TABLE ACCESS (BY INDEX ROWID) OF 'LINK$' (TABLE) (Cost
          =0 Card=1 Bytes=88)
   8    7         INDEX (RANGE SCAN) OF 'I_LINK1' (INDEX) (Cost=0 Card
          =1)
Statistics
          0  recursive calls
          0  db block gets
        726  consistent gets
          0  physical reads
          0  redo size
       8804  bytes sent via SQL*Net to client
        574  bytes received via SQL*Net from client
          8  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
        105  rows processed
DEV@TEST>You should have an idea why there's a difference in execution time by comparing the results.
Regards,
Tony Garabedian

Similar Messages

  • SQl statement cause extreme Portal log growth

    Our Portal server log file is growing very fast (30 - 50 Mb per minute). When examining the log file we see that the log file does contain only the error messages:
    #1.5#00096BF521750058005A9CA900001E480003E80BD8A2C263#1099562506968#/System/Database/sql/jdbc/common#sap.com/irj#com.sap.sql.jdbc.common.StatementAnalyzerImpl#Guest#18####655e44612e4811d9b41300096bf52175#Thread[ThreadPool-Dispatcher,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error#1#com.sap.sql.jdbc.common.StatementAnalyzerImpl#Java#com.sap.sql.jdbc.common_1123#com.sap.sql.log.OpenSQLResourceBundle#The SQL statement "" contains the semantics error[s]: #2#SELECT MIN("ID"),"PRIORITY" FROM "KMC_TQ_QUEUE" WHERE "NAMESPACE_HASH" = ? AND "NAMESPACE" = ? AND "TASK_STATE" = 1 GROUP BY "PRIORITY" ORDER BY 2 DESC#type check error: the expression >>"NAMESPACE"<< (LONGVARCHAR) is not comparable and must not be used with "="
    This message occurs more than 500 times per log file. It has something to do with Knowledge management, but we cannot find anything that triggers this sql statement.
    Any ideas?
    Noel Hendrikx & Pascal Rijnart

    SAP tells us in reaction to our customer message:
    "The table's definition is correct. What has to be changed is the
    computed type for field NAMESPACE and the generated file for the table.
    As I wrote before, if you make any change in the field NAMESPACE the
    new computation is started (so change the description which has no
    effect on the table's version on the database). Make the change and
    save the table in the SapNetWeaver Developer Studio. You will then
    see that the field's JDBC-type changes to VARCHAR.
    Choose 'Create archive' for Dictionary Project the table belongs to
    and deploy the sda on the database. Both can be done in the studio."
    Can anyone tell us what to do now?
    Noel Hendrikx

  • Sql statement causes my JRun server to fail.

    I'm beginning JSP and can't go through this recurrent error: the first request to the JSP page containing sql statement works well, in the second, an error occurs and finally, the third forces my Jrun server to fail with a stack error...
    <CODE>
    <%-- page global declaratiosn --%>
    <%@ page import="java.sql.*,javax.sql.*,allaire.taglib.*" %>
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
    String url = "jdbc:odbc:ademeregion" ;
    Connection con = DriverManager.getConnection( url , "" , "" ) ;
    Statement stmt = con.createStatement();
    ResultSet itom = stmt.executeQuery( "SELECT * FROM ITOM" ) ;
    ResultSetMetaData itomMetaData = itom.getMetaData( ) ;
    out.print( getServletContext().getInitParameter( "test" ) + "<br>" ) ;
    %>
    <table border=1 cellspadding=0 cellspacing=0>
    <%
    while( itom.next() ){%>
    <tr>
    <%
    for (int i = 1 ; i <= itomMetaData.getColumnCount() ; i++ ){
    out.print( "<td><font face=Verdana color=#EEEEEE size=1>" + itom.getString( i ) + "</font></td>") ;
    %>
    </tr><%
    %>
    </CODE>
    I assume it could be a typical jdbc problem that beginners encounter...
    Help required...
    Thanks a lot...
    Sylvain

    Thnks but it's allready done:
    I had the following code allready:
    <%
    itom = null ;
    itomMetaData = null ;
    stmt.close( ) ;
    con.close( ) ;
    %>
    But thanks anyway...

  • High SQL activity causing delays in jobs starting

    Experts,
    We are having a problem nearly exactly the same time of day each day where jobs scheduled to execute during a roughly 10 minute interval are delayed in there start because of what we think is extra high SQL activity. Our conclusion is based on the observation that during this period the following SQLs are being executed 19400+ and 7100+ time respectively"
    SELECT J.STATUS , J.NEWSTATUS , S.LEVEL# , J.OUT$OSNAME , J.OBJ# , J.REMOTE_STATUS FROM RWS_JOB$ J , RWS_STA$ S WHERE J.JOB# = :1 AND S.STATUS = J.STATUS AND ( J.STATUS != :1 OR J.SCH$NAME IS NULL ) FOR UPDATE OF J.STATUS
    SELECT VALUE_VCH FROM JCS_JOB_PARAMETERS WHERE JOB_ID = :1 AND PARAMETER_NAME = 'PARENT_WAIT_FOR_CHILD'
    We have traced this back to a package called RSISYS.
    Can anyone shed some light as to what may be happening and what steps we need to perform to alleviate the situation.
    Thanks.
    Kind Regards,
    David Carr

    Hi,
    The following applies to the standalone version only, which is the version you are using.
    Since it always occurs at roughly the same time, it is probably something recurring.
    It could be that you are starting a lot of jobs at the same time, either in CPS or in SAP (if CPS monitors SAP jobs as well).
    But you would probably be aware of that.
    It can also be the "DeleteCheck" of the RFC agent: please check in the registry the values for "History" and "DeleteCheckInterval" for your SAP system(s).
    Finally there are a few system jobs that can have similar effects, such as RSI_SYNC_CCMS_JOBS if there are a lot of jobs to check.
    Regards,
    Anton.

  • FLEXFIELD DEFAULT SQL STATEMENT

    Hello all.
    I created a flexfield on the PO Lines with a default type of sql statement. The statement
    uses the po_lines item id, however when accessing the PO Summary form the default statement
    seems to be firing prior the po line block is accessed and causing the sql statement to raise
    some exception. Is there a way around this?
    thanks and more power.

    iccsi wrote:
    My question is the 300 queries can be simplified as a simple SQL like
    Select MyName, count(MyID)  from myTable
    where myName =  'Name1'
    group by MyName
    Select MyName, count(MyID) from myTable
    where myName = 'Name2'
    group by MyName
    Select MyName, count(MyID) from myTable
    where myName = 'Name3'
    group by MyName
    can be some one use like following
    Select MyName, count(MyID) from myTable
    group by MyName
    or save as a stored procedure which the web server or web page only hit database server once instead of 300 times.
    I would like to know does ColdFusion is smart enough to know the SQL are similar and only run SQL once against dabase server.
    In my opinion, query-of-a-query is a smart enough solution to the problem. In the following example, ColdFusion visits the database just once!
    <cfquery name="mainQuery" datasource="myDSN">
    select MyName, count(MyID) from myTable
    group by MyName
    </cfquery>
    <cfquery dbType="query" name="subQuery1">
    select *
    from myQuery
    where myName =  'Name1'
    </cfquery>
    <cfquery dbType="query" name="subQuery2">
    select *
    from myQuery
    where myName =  'Name2'
    </cfquery>
    <cfquery dbType="query" name="subQuery300">
    select *
    from myQuery
    where myName =  'Name300'
    </cfquery>

  • Can I capture the SQL statement cuasing an error?

    I have an error log that capures SQLCODE & SQLERRM.
    Can I also capture the actual SQL statement causing the error?

    there is also format call stack, format error stack and format error backtrace.
    /* Formatted on 6/21/2011 3:45:40 PM (QP5 v5.149.1003.31008) */
    BEGIN
       FOR c IN (SELECT TO_NUMBER ('hey Im not a number') FROM DUAL)
       LOOP
          NULL;
       END LOOP;
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.PUT_LINE ('SQLCODE :' || SQLCODE);
          DBMS_OUTPUT.PUT_LINE ('SQLERRM :' || SQLERRM);
          DBMS_OUTPUT.
           put_line (
             'call stack...' || CHR (10) || DBMS_UTILITY.FORMAT_call_STACK ());
          DBMS_OUTPUT.
           put_line (
             'Error_Stack...' || CHR (10) || DBMS_UTILITY.FORMAT_ERROR_STACK ());
          DBMS_OUTPUT.
           put_line (
                'Error_Backtrace...'
             || CHR (10)
             || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE ());
          DBMS_OUTPUT.PUT_LINE ('----------');
          RAISE;
    END;
    SQLCODE :-1722
    SQLERRM :ORA-01722: invalid number
    call stack...
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    c0000002a56b4248        11  anonymous block
    Error_Stack...
    ORA-01722: invalid number
    Error_Backtrace...
    ORA-06512: at line 2
    ----------

  • Adding a field to an sql statement in Oracle Reports error ORA-00933

    We have been requested to add a field that already exists in the table referred to by the sql statement in Oracle Reports Builder. The report was set up by a consultant about 3 yrs ago and we don't really have much skill in this area. What is happening when I try to modify the SQL statement, either adding a field or deleting a field to the SELECT statement, causes an error message preventing the statement from being saved. The only way out of the error message is to click Cancel. The error message is
    ORA-00933:SQL command not properly ended
    ORDER BY Program ==> NAME
    Even adding or deleting a space anywhere in the SQL statement causes the error (not adding any new fields). A coworker found that if we comment out the ORDER BY, the statement will accept the new field in the SELECT section, however then we lose the order by functionality. I would like to add one additional field before the FROM. Not sure if any additional data are needed. Thank you.
    SELECT p.person_uid PIDM_KEY, p.id_number ID,
                   p.full_name_lfmi name,            
                    p.BIRTH_DATE, p.GENDER Sex,
                    Decode(a.residency,'D',p.Primary_ethnicity,'F')  Ethn,
                    a.academic_period TERM,        
                    CASE WHEN :p_group_by = 'PROGRAM' THEN a.program
                                 ELSE ' '
                    END AS Program,
                    a.COLLEGE, a.degree, a.major, ' ' rule,
                    a.STUDENT_POPULATION,a.STUDENT_LEVEL,    a.application_status Status,  a.application_status_date app_sts_dte,
                    ad.decision_date1 Last_Dec_Date,
                    ad.decision1||' '||ad.decision2||' '|| ad.decision3||' '|| ad.decision4||' '|| ad.decision5 Decisions,
                    /*  Deposit Date uses the last term entered in :p_term parameter string */
                    (SELECT MAX(deposit_effective_date) FROM usf_as_deposit WHERE account_uid = a.person_uid &term_clause group by account_uid)   AS "DEPOSIT DATE",     
                    ph.phone as PHONE,
                    CASE WHEN PS.FIRST_CONTACT IN ('NET','PAP','COM','COP') THEN PS.First_Contact
                     ELSE CASE WHEN ps.latest_contact IN ('NET','PAP','COM','COP') THEN PS.Latest_Contact
                                ELSE '  '
                                END
                    END AS FIRST_CONTACT,
                    DECODE(:p_address,'Y',REPLACE(adr.street1||' '||adr.street2||' '||adr.street3||' '||adr.city||','||adr.state||' '||adr.nation||' '||adr.zip,'  ',' '),' ') as  address, adr.nation, adr.state,
                    goremal_email_address email, a.residency, a.application_date, p.primary_ethnicity, c.cohort
    FROM MST_ADMISSIONS_APPLICATION A,
               MST_PERSON p,mst_pre_student PS,  Admissions_Cohort c, usf_v_phone_pr_ma ph,
               MST_admissions_decision_slot AD, usf_v_email, usf_v_address_dr_lr_ma_pr adr
    WHERE a.PERSON_UID = p.person_uid
            AND a.curriculum_priority  = 1
            AND a.person_uid = ps.person_uid
           AND a.person_uid = ad.person_Uid(+)
           AND a.person_uid = goremal_pidm(+)
           AND a.person_uid = adr.pidm(+)
           AND a.person_uid = ph.pidm(+)
           AND ph.rnum(+) = 1
           AND a.person_uid = c.person_uid(+)
           AND a.academic_period = c.academic_period(+)
      &Where_Clause
           /*    TAKE OUT FOLLOWING LINE AFTER DATA IS CLEANED UP  */
            AND NOT(p.id_number = '00000000'   OR SUBSTR(p.id_number,1,1) = 'B'  OR UPPER(p.full_name_lfmi)  LIKE '%TESTING%')
           AND  a.application_status_date >= NVL(:p_as_of_date,sysdate-8000)
           AND a.academic_period = ad.academic_period(+)
            AND a.application_number = ad.application_number(+)
            AND a.degree <> 'ND'    /*   AND a.college <> 'LW'                         --  Does not need non-degree and law students    */
           &Cohort_Clause 
    ORDER BY Program  &ORDER_CLAUSE

    Hi Denis,
    I tried your suggestion. The good thing is that adding the comma allowed me to be able to add a.campus to the select statement, unfortunately, another error message happened.
    ORA-00936: missing expression SELECT p . person_uid PIDM_KEY ,
    p . id_number , p . full_name_lfmi name , p . BIRTH_DATE , p . GENDER Sex ,
    Decode ( a . residency , 'D' , p . Primary_Ethnicity , 'F' ) Ethn , a . academic_period TERM ,
    CASE WHEN : P_group_by = 'PROGRAM THEN a I started over and tried only putting in the comma and get the same message even though I didn't add campus. After that, removed the comma which led to the ORA-00933 error message. So once again, I had to close the file without saving, in order for the report to run at all.

  • About hints in sql statements

    hi,
    can you plz provide any best sides for sql hints?

    Suri wrote:
    You can learn basics from below site.
    http://www.dbasupport.com/oracle/ora9i/index_hints.shtml
    What an awful article...
    >
    Using Index Hints in SQL statements - Cause we know more about our application than Oracle does
    Hints are used to give specific information that we know about our data and application, to Oracle. This further improves the performance of our system. There can be instances where the default optimizer may not be efficient for a certain SQL statements. We can specify HINTS with the SQL statements, to improve the efficiency of those SQL statements.
    <cut>
    By using Hints, you can improve certain SQL statements that might otherwise be inefficient.
    >
    That is just so wrong and completely misses the point.
    If a query is inefficient, then it can be down to poor database design, lack of statistics, lack of correct indexes (sometimes too many indexes), or poorly written SQL statements. Hacking an SQL statement with Hints to try and make it work better because you believe you "know more about our application than Oracle does", shows a complete lack of understanding of the internals of Oracle. Oracle doesn't need to know about the application, but it certainly does need to know about how the data is stored and related on the underlying tables and in the tablespaces and datafiles etc. and it's sure as hell got a better idea about that than any programmer, especially as it can change and adapt in the future as the data changes, which a programmers SQL statements (with fixed hints) won't.
    That article is a good example of the wrong attitude towards using hints. Thanks for posting that to demonstrate it.

  • How to run a sql statement with bind variable in a test environment

    Hello,
    I have a sql statement in prod that I like to run in test. I got the sql statement from statspack, but the statement has bind variables. How do I get this statement to run in test? Thank you.

    Hi,
    If you have the SQL statement and all the referenced objects are available in your test env then what is the problem to run it?
    If I am not wront to get your reqmnt...
    i.e
    SQL> select * from emp
    where emp_no = &empno
    and dept_code = &deptcode;
    Thanks

  • SQL  Statement tuning

    Hi,
    Some Sql statement is taking so much time to run. Performance wise it is very slow. How to tune Such SQL statemetns.Would you plase give steps for tuning.
    Please any body reply on this...

    Hi Satishbabu,
    Try to get an PLAN on your sql statement, run EXPLAIN PLAN and check the statistics, if required, try using HINTS and see the difference in the COST.
    Can you paste your sql statement in this forum?

  • SqlDependency causing delays to UPDATE statements

    I have a win forms application which uses SqlDependency to monitor an orders table for changes (ie when goods are shipped etc).  The SQL statement works fine but I am having trouble with other SQL statements wanting to update the orders table whilst
    the SqlDependency is monitoring the table.
    Initially I thought it was down to the transaction containing the update statements but if I take just one simple update statement and run it in SQL Management Studio, I get the same delay between 10 and 20 seconds.  It appears to be the case for just
    this one table which is monitored, other tables which are included in the SqlDependency SQL statement through inner joins are updated fine (<1 second).
    Anyone any ideas on what could cause this or where to start troubleshooting?
    Also, this is in a production system and the table in question has circa 19k rows.  I don't see this problem in my dev system which has fewer rows.
    Chris

    Hello,
    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
    Thank you for your understanding and support.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here.
    Fanny Liu
    TechNet Community Support

  • Usage of Xopen SQL states and SQL Exception?

    Hi
    Is there way to make full use of SQL Exceptions?
    Has anybody used sql states from sql exception?
    It is specified in the API reference that an sql exception object contains an xopen sql state which is a string. But the states in specs are defined as class, subclass.
    The question is how can i make use of these java strings to interpret what exactly happened at the database? Are they really useful? If they are, any utilities which converts these strings to a meaningful message? Any pointers on these question would also help me.
    Thanx in adv.
    Giridhar

    SQLException has inherited a method getMessage() which seems to be quite useful.
    For situations where you want to check on a specific one of several possible (or expected) states (like: maybe the table is not yet created ...), I think you can quite fine use getSQLState() and also getErorCode(). Try out in tests, which information is returned by which constellation, then you can use it for making decisions in your program logic.
    But be aware, that all these informations probably are DBMS specific!

  • Using SQL Statements in Error Exceptions

    Is there any way to include SQL statements within my catch routines (i.e.
    catch (java.io.IOException ex) {
    System.out.println("An error occurred whilst writing to the message buffer: " + ex);
    #sql { INSERT INTO DEBUG_TBL(CURRENT_DT,PROGRAM_ID,DEBUG__MESG) VALUES (SYSDATE,'TEST',:ex) };
    #sql { COMMIT };
    As it stands I get the following error upon compile:
    Error: Unsupported Java type for host item (at position#1): java.io.IOException
    Any help would be greatly appreciated.
    Thx,
    Boybles
    null

    You can use SQL statements in your catch blocks, just not SQL statements that use Java types which do not map to SQL.
    You cannot pass exceptions from Java to SQL. You can catch a SQL exceptions as a SQLException in Java. However, any exception that is thrown by a Java Stored Procedure (including SQLException) is rendered as an "Uncaught Java exception" in SQL.
    When you receive a SQLException there is information about the originator, the error message, etc. in the exception object. See:
    http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/a83723/keyprog5.htm#1004462
    While you cannot insert a Java exception per se into a table, you can extract the message string(s)/code and insert that in a table.

  • What can be the cause of Web ADI error : Cannot execute SQL statement?

    I created a custom integrator in r12.2.3 and while loading I encountered an error, Cannot execute SQL statement.
    I checked my setup in Interface attribute , the RUN_ID column has a default type SQL QUERY with a default value SELECT  XXCONV_EAM_ASSET_NUM_S.NEXTVAL FROM DUAL.
    If I have a right setup here, what can be the cause of this error?

    Hi,
    The possibilities can be of various reasons, with the sql statements,
    xml descriptors, data sources, improper drivers anything. To crack down
    the solution, kindly let me know the error messages and what exactly are
    you trying to accomplish.
    Thanks & Regards
    Raj
    manimaran t wrote:
    what may be the cause of this error java.sql.SQLException: invalid sql
    type passed to callable statement in iplanet ussing JNDI
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • ORA-01555 caused by SQL statement below on production

    Hi
    i got ORA-01555 caused by SQL statement below on my prodution adn database undo_retention = 18000 what can i do my database performance is going down pls tail me what i do .
    Regards
    Digvijay

    1) I don't see a SQL statement here
    3) How did you determine that UNDO_RETENTION of 18000 was appropriate?
    4) How much UNDO is your system generating?
    6) Do you believe this is related to your performance problems? If so, why do you believe that?
    At the risk of stating the obvious... You've told Oracle to try to maintain UNDO for 18,000 seconds (5 hours). You have a query that runs for roughly 6.25 hours. If, after running for 6.25 hours, that query needs a block that was modified, say, 6 hours ago, it may not find it because you've told Oracle you don't need it any longer.
    Your UNDO_RETENTION needs to be greater than the longest-running query you expect to run. You can bump up UNDO_RETENTION if you'd like. However, I tend to believe that a query that died after 6.25 hours is probably a query that is in desparate need of tuning. If you reduce the query runtime to something less than 5 hours, you could keep UNDO_RETENTION at the current setting.
    Justin

Maybe you are looking for