Query execution slow on Production but fine on test DB

Oracle database : 11.1.0.7.0
Hi all ,
There is a query which is taking more than one hour to execute on production but executes within 4 minutes.
I generate the statspack report on both and this is what it says:
On Production(taken at a duration of 13 min)
Instance CPU
~~~~~~~~~~~~ % Time (seconds)
Host: Total time (s): 12,980.
Host: Busy CPU time (s): 836.4
% of time Host is Busy: 6.4
Instance: Total CPU time (s): 820.0
% of Busy CPU used for Instance: 98.0
Instance: Total Database time (s): 823.3
%DB time waiting for CPU (Resource Mgr): 0.0
Virtual Memory Paging
~~~~~~~~~~~~~~~~~~~~~
KB paged out per sec: 952,086,497.1
KB paged in per sec: ##############
Instance Activity Stats DB/Inst: ABDCRS/abdcrs Snaps: 6-7
Statistic Total per Second per Trans
buffer is not pinned count 73,698,340 90,761.5 383,845.5
buffer is pinned count 2,115,542,366 2,605,347.7 ############
bytes received via SQL*Net from c 439,101 540.8 2,287.0
bytes sent via SQL*Net to client 223,265 275.0 1,162.8
calls to get snapshot scn: kcmgss 54,195 66.7 282.3
calls to kcmgas 1,316 1.6 6.9
calls to kcmgcs 129 0.2 0.7
cell physical IO interconnect byt 432,079,872 532,118.1 2,250,416.0
change write time 62 0.1 0.3
concurrency wait time 14 0.0 0.1
consistent changes 843 1.0 4.4
consistent gets 77,570,007 95,529.6 404,010.5
consistent gets - examination 40,685 50.1 211.9
consistent gets direct 0 0.0 0.0
consistent gets from cache 77,570,007 95,529.6 404,010.5
consistent gets from cache (fastp 77,523,523 95,472.3 403,768.4
cursor authentications 0 0.0 0.0
opened cursors cumulative 49,290 60.7 256.7
On test Database (taken at a interval of one and a half min)
Instance CPU
~~~~~~~~~~~~ % Time (seconds)
Host: Total time (s): 134.0
Host: Busy CPU time (s): 37.1
% of time Host is Busy: 27.7
Instance: Total CPU time (s): 26.5
% of Busy CPU used for Instance: 71.5
Instance: Total Database time (s): 100.5
%DB time waiting for CPU (Resource Mgr): 0.0
Virtual Memory Paging
~~~~~~~~~~~~~~~~~~~~~
KB paged out per sec: 6.8
KB paged in per sec: 26.1
Instance Activity Stats DB/Inst: ABDCRS/abdcrs Snaps: 2-3
Statistic Total per Second per Trans
buffer is not pinned count 799,850 11,762.5 49,990.6
buffer is pinned count 458,511 6,742.8 28,656.9
bytes received via SQL*Net from c 888,978 13,073.2 55,561.1
bytes sent via SQL*Net to client 5,980,608 87,950.1 373,788.0
calls to get snapshot scn: kcmgss 245,953 3,617.0 15,372.1
calls to kcmgas 818 12.0 51.1
concurrency wait time 2 0.0 0.1
consistent changes 7 0.1 0.4
consistent gets 1,037,292 15,254.3 64,830.8
consistent gets - examination 421,021 6,191.5 26,313.8
consistent gets direct 96,012 1,411.9 6,000.8
consistent gets from cache 941,280 13,842.4 58,830.0
consistent gets from cache (fastp 358,400 5,270.6 22,400.0
current blocks converted for CR 0 0.0 0.0
opened cursors cumulative 239,029 3,515.1 14,939.3
Now as u can see the value for " bytes sent via SQL*Net to client" on test is very high for a one min window but on prod it is very low even for a 13 min window also value for consistent gets on prod in extremely high as compared to test database and test db is doing more execution in one min than prod database in 15 min.Now these are the major differences on prod and test could this be the reason for slow execution of query on prod? and how do I fix it
Also value for opened cursors cumulative for test is high but it is low on prod.I don't have the awr report as database is standard edition Looking forward to your reply
Thanks
Saurav

Pl use \ tags to make your post more readable - http://wiki.oracle.com/page/Oracle+Discussion+Forums+FAQ
When your query takes too long:
HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long ...
HTH
Srini                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Slow performance in production but fine in testing

    Hi,
    I wanted to know that what are the possible reasons that the query work fine in testing phase but slow in production phase.
    Thanks

    user8379622 wrote:
    We have various schemas on one server where the production data kept and have another server where the consistency check of data performed.
    We have one application that run on set of data and generate the log in ascii format and then query on database and after that using sqlldr dump the data into oracle.
    Testing team has tested the application by parallelly 10 processes and it upload the data within a sec but in the production env sometimes it run fine and sometimes it take ~4-6 min.
    We tried but not able to find out the reason if it is at database level or application level issue. Statistics on database are fine.
    Could you please suggest the possible causes so i will try to verify all the thing one by one to crack the issue.
    ThanksYou need to instrument the application so it tells you where to look. For example, your log files could have comments of when they started and finished. This way you find out if it is your app connecting, your query running, your sqlldr being slow or some combination.
    If it is the app connecting, then you can try other ways of connecting when the problem is happening, as well as checking the app and sqlnet logs for clues. If it is the query, you can use various methods to see what plan it is using - it is entirely possible that your data distribution is near some boundary condition that causes it to switch plans with very slight changes in data. You can also look at locks and waits to see if something is slowing it or the load down. There are a number of things that could change load performance - are you using direct path? Are other users updating at that time? How exactly are you implementing parallel?
    I've found the basic dbconsole performance screen often points me in the right direction, especially being able to drill down to an explain plan for a session.
    How do you know the "statistics on the database are fine?" Some plans can be messed up because of the default statistics gathering in some versions. Which versions and patch levels of everything are you using?

  • Query execution slow

    Hi Experts,
    I have problem with query execution. It is taking more time to execution.
    Query is like this :
    SELECT   gcc_po.segment1 bc,
             gcc_po.segment2 rc,
             gcc_po.segment3 dept,
             gcc_po.segment4 ACCOUNT,
             gcc_po.segment5 product,
             gcc_po.segment6 project,
             gcc_po.segment7 tbd,
             SUBSTR (pv.vendor_name, 1, 50) vendor_name,
             pv.vendor_id,
             NVL (ph.closed_code, 'OPEN') status,
             ph.cancel_flag,
             ph.vendor_site_id,
             ph.segment1 po_number,
             ph.creation_date po_creation_date,
             pv.segment1 supplier_number,
             pvsa.vendor_site_code,
             ph.currency_code po_curr_code,
             ph.blanket_total_amount,
             NVL (ph.rate, 1) po_rate,
             SUM (DECODE (:p_currency,
                          'FUNCTIONAL', DECODE (:p_func_curr_code,
                                                ph.currency_code, NVL
                                                                (pd.amount_billed,
                                                                 0),
                                                  NVL (pd.amount_billed, 0)
                                                * NVL (ph.rate, 1)
                          NVL (pd.amount_billed, 0)
                         )) amt_vouchered,
             ph.po_header_id poheaderid,
             INITCAP (ph.attribute1) po_type,
             DECODE (ph.attribute8,
                     'ARIBA', DECODE (ph.attribute4,
                                      NULL, ph.attribute4,
                                      ppf.full_name
                     ph.attribute4
                    ) origanator,
             ph.attribute8 phv_attribute8,
             UPPER (ph.attribute4) phv_attribute4
        FROM po_headers ph,
             po_vendors pv,
             po_vendor_sites pvsa,
             po_distributions pd,
             gl_code_combinations gcc_po,
             per_all_people_f ppf
       WHERE ph.segment1 BETWEEN '001002' AND 'IND900714'
         AND ph.vendor_id = pv.vendor_id(+)
         AND ph.vendor_site_id = pvsa.vendor_site_id
         AND ph.po_header_id = pd.po_header_id
         AND gcc_po.code_combination_id = pd.code_combination_id
         AND pv.vendor_id = pvsa.vendor_id
         AND UPPER (ph.attribute4) = ppf.attribute2(+) -- no  index on attributes
         AND ph.creation_date BETWEEN ppf.effective_start_date(+) AND ppf.effective_end_date(+)
    GROUP BY gcc_po.segment1,-- no index on segments
             gcc_po.segment2,
             gcc_po.segment3,
             gcc_po.segment4,
             gcc_po.segment5,
             gcc_po.segment6,
             gcc_po.segment7,
             SUBSTR (pv.vendor_name, 1, 50),
             pv.vendor_id,
             NVL (ph.closed_code, 'OPEN'),
             ph.cancel_flag,
             ph.vendor_site_id,
             ph.segment1,
             ph.creation_date,
             pvsa.attribute7,
             pv.segment1,
             pvsa.vendor_site_code,
             ph.currency_code,
             ph.blanket_total_amount,
             NVL (ph.rate, 1),
             ph.po_header_id,
             INITCAP (ph.attribute1),
             DECODE (ph.attribute8,
                     'ARIBA', DECODE (ph.attribute4,
                                      NULL, ph.attribute4,
                                      ppf.full_name
                     ph.attribute4
             ph.attribute8,
             ph.attribute4Here with out SUM funciton and group by function its execution is fast. if i use this Sum function and Group by function it is taking nearly 45 mins.
    Explain plan for this:
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=ALL_ROWS          1             6364                              
      HASH GROUP BY          1       272       6364                              
        NESTED LOOPS OUTER          1       272       6363                              
          NESTED LOOPS          1       232       6360                              
            NESTED LOOPS          1       192       6358                              
              NESTED LOOPS          1       171       6341                              
                HASH JOIN          1 K     100 K     2455                              
                  TABLE ACCESS FULL     PO_VENDOR_SITES_ALL     1 K     36 K     1683                              
                  TABLE ACCESS FULL     PO_VENDORS     56 K     3 M     770                              
                TABLE ACCESS BY INDEX ROWID     PO_HEADERS_ALL     1       82       53                              
                  INDEX RANGE SCAN     PO_HEADERS_N1     69             2                              
              TABLE ACCESS BY INDEX ROWID     PO_DISTRIBUTIONS_ALL     1       21       17                              
                INDEX RANGE SCAN     PO_DISTRIBUTIONS_N3     76             2                              
            TABLE ACCESS BY INDEX ROWID     GL_CODE_COMBINATIONS     1       40       2                              
              INDEX UNIQUE SCAN     GL_CODE_COMBINATIONS_U1     1             1                              
          TABLE ACCESS BY INDEX ROWID     PER_ALL_PEOPLE_F     1       40       3                              
            INDEX RANGE SCAN     PER_PEOPLE_F_ATT2     2             1                               plz giv me solution for this.....Whihc Hints shall i use in this query.....
    thanks in ADV....

    I have a feeling this will lead us nowhere, but let me try for the last time.
    Tuning a query is not about trying out all available index hints, because there must be one that makes the query fly. It is about diagnosing the query. See what it does and see where time is being spent. Only after you know where time is being spent, then you can effectively do something about it (if it is not tuned already).
    So please read about explain plan, SQL*Trace and tkprof, and start diagnosing where your problem is.
    Regards,
    Rob.

  • In-Memory Query execution mode rendering results but "both" as execution mode do not.

    Hi,
    I am facing this strange issue of fetching some rows based on my view criteria.
    I delete some rows and make them as inactive. Then I search for those rows by using filter as "inactive" rows. I get the result as expected. But then, if I enter any other filed apart from inactive condition, I do not get that record even when that record is present in the list.
    I looked out for the query execution mode for my VC based on which my rows are fetched. I found that if I keep the Query execution mode as "In-Memory" I am able to get the result but if I give the query execution mode as "Both", I do not get results even though the other factors are still same for it.
    Due to model settings, I can't use "In-Memory" as the query execution mode.
    I get the results properly after I commit my changes to DB,however.
    How can I proceed here?

    Hi,
    apparently the JDeveloper version you use does not work with "Both", which I suspect to be a bug. If you are on a latest version of JDeveloper 11g R1, JDeveloper 11g R2 or on JDeveloper 12c, please file a bug if you have access to customer support. If you are not yet on a latest version of JDeveloper, please try a newer version of your JDeveloper release.
    Frank

  • Runtime error in production but working in test

    Hi all gurus!<br><br>
    We have an interesting problem with two own developed Java DynPage components. They both have inputfields that are put in a table by a TableViewCellRenderer. The code looks like this and is pretty straight forward:<br><br>
         InputField dateField = new InputField(Constants.startDateTag);<br><br>
         // Now we set the string for inputField from the model, so that the selections<br>
         // already made in the tableView don't get lost<br><br>
         // Get current date<br>
         String dateString=tableView.getValueAt(row, column).toString();<br><br>
         // Check if empty string<br>
         if(dateString == null || (dateString !=null && dateString.trim().equals("")))<br>
         {<br>
              //Get current date<br>
              dateString=CalendarUtil.getCurrentDate();<br>
         }<br><br>
         // Set current date<br>
         dateField.setString(dateString);<br><br>
         // Now we set the datatype to DATE and SHOWHELP to TRUE<br>
         dateField.setType(DataType.DATE);<br>
         dateField.setShowHelp(true);<br>
         dateField.setDesign(InputFieldDesign.SMALL);<br><br>
         // Set the renderer<br>
         dateField.render(rendererContext);<br><br>
    This code gives a nullpointerexception. The error stack in the default trace points to the following row:<br>
    dateField.setType(DataType.DATE);<br><br>
    The complete error stack is at the end of the post.<br><br>
    As I said in the header it works fine in test but not in production. We have copied the production database to test to eliminate the influence of erroneous data. What we found is that the components still worked in test so the data itself is not the source of the problem, which also the error message gives a hint of.<br><br>
    Does anyone have an idea about what the problem could be? I have torn the little hair I still have on my head over this problem. ;)<br><br>
    Best regards<br>
    Benny<br><br><br>
    Full Message Text<br><br>
    10:59_30/03/10_0059_13822150<br>
    [EXCEPTION]<br>
    java.lang.NullPointerException<br>
    at com.sapportals.htmlb.InputField.setType(InputField.java:206)<br>
    at com.bergendahls.bgvendor.gui.TableViewCellRenderer.renderCell(TableViewCellRenderer.java:69)
    at com.sapportals.htmlb.unifiedrendering.ie5.TableViewRenderer.renderTableViewCellFragment(TableViewRenderer.java:1967) <br>
    at com.sapportals.htmlb.unifiedrendering.ie5.TableViewRenderer.renderTableViewRowFragment(TableViewRenderer.java:1522) <br>
    at com.sapportals.htmlb.unifiedrendering.ie5.TableViewRenderer.renderTableViewFragment(TableViewRenderer.java:400)<br>
    at com.sapportals.htmlb.unifiedrendering.ie5.TableViewRenderer.render(TableViewRenderer.java:106) <br>
    at com.sapportals.htmlb.rendering.PageContext.render(PageContext.java:999) <br>
    at com.sapportals.htmlb.taglib.TableViewTag.doEndTag(TableViewTag.java:139) <br>
    at pagelet._sapportalsjsp_PriceListSearch.subDoContent(_sapportalsjsp_PriceListSearch.java:284) <br>
    at pagelet._sapportalsjsp_PriceListSearch.doContent(_sapportalsjsp_PriceListSearch.java:45) <br>
    at pagelet._sapportalsjsp_PriceListSearch.service(_sapportalsjsp_PriceListSearch.java:29) <br>
    at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.service(PortalComponentItemFacade.java:360) <br>
    at com.sapportals.portal.prt.core.broker.PortalComponentItem.service(PortalComponentItem.java:934) <br>
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:435) <br>
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:527) <br>
    at com.sapportals.portal.prt.core.async.AsyncPortalComponentResponse.include(AsyncPortalComponentResponse.java:680) <br>
    at com.sapportals.portal.htmlb.page.JSPDynPage.doOutput(JSPDynPage.java:76) <br>
    at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:133) <br>
    at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134) <br>
    at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209) <br>
    at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114) <br>
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328) <br>
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136) <br>
    at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable$1$DoDispatchRequest.run(AsyncIncludeRunnable.java:375) <br>
    at java.security.AccessController.doPrivileged(Native Method) <br>
    at com.sapportals.portal.prt.core.async.AsyncIncludeRunnable.run(AsyncIncludeRunnable.java:388) <br>
    at com.sapportals.portal.prt.core.async.ThreadContextRunnable.run(ThreadContextRunnable.java:164) <br>
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:729) <br>
    at java.lang.Thread.run(Thread.java:534)

    Problem solved.
    The reason for the error was a tricky one. The InputField was instantiated using the constructor with an Id as in-parameter. Unfortunately the Id contained special characters, an unfortunate slip of mind.
    What made this error so difficult two find were two things.
    First: the solution worked in Test but not in Production. One would think that the Id should create a problem in both environments or in none.
    Second: after the instantiation of the inputfield it accepted inputfield.setText("..."); but then crashed at the following row "inputfield.setType(DataType.DATE);. One would have expected the component to crash at the first manipulation.
    I hope this can help other persons who have made an unfortunate choice of Id.
    Best regards
    Benny
    Edited by: Benny Lange on Mar 31, 2010 1:51 PM

  • Query execution slow for the first time...

    I am new to Oracle sql.
    I have a query whose performance is very slow for the first time, but on subsequent executions its fast. When executed for the first time it is taking around 45 seconds and on subsequent executions, 600 milliseconds.
    Is there a specific reason for this to happen. I am calling this query from my java code using a prepare statement.

    Are the differences in queries solely in the where clause? If so can you parameterize the query and use bind variables instead so the only difference from one query to the next is the values of the bind variables? Using bind variables in your queries will enable the parser to reuse the already parsed queries even when the bound values differ.
    Also there may be other optimizations that can be made to either your query or the tables that it is querying against to improve your performance. To be able to improve your queries performance you need to understand how it's accessing the database.
    See Rob's thread on query optimization [When your query takes too long |http://forums.oracle.com/forums/thread.jspa?threadID=501834&start=0&tstart=0] for a primer on optimizing your query.

  • Query not executing on production but on dev server

    Hi,
    I have few queries which are running in less then a second in development server but couldn't get executed on production server in three hours. Production box is much heavier then the development server. I have verified the init.ora parameters. both the boxes have same parameters and same data. How should I start the investigation on the same problem?
    Need urgent help.
    Thanks is Advance.
    Thanks, Dewan

    user463820 wrote:
    Production box is much heavier then the development server. I have verified the init.ora parameters. both the boxes have same parameters and same data.Which might be a contributing factor to:
    I have few queries which are running in less then a second in development server but couldn't get executed on production server in three hours. Do you have QA environment with production-like data? In any case, make sure statistics is collected and is up to date. Get explain plan for queries in question. See if execution plan isn't optimal.
    SY.

  • Site slow on Firefox but fine on both IE and other computers running Firefox?

    Hi,
    I'm having a weird problem and I don't have a clue what is wrong.
    Whenever I try to load this specific website: http://motleycrewmcs.co.uk/news.php it takes a good 20 or so seconds to load, but on Internet Explorer it loads almost immediately. Now the funny thing is I have tried loading this same site using Firefox on other computers and it loads fine.
    I originally had this problem with Firefox 3.6 and I tried clearing my cache, recent history etc. I then tried running Firefox in Safe Mode (all addons disabled) etc but I still had the same loading issue.
    Then in an attempt to fix it I completely uninstalled Firefox, deleted the installation folder, deleted the Profile AppData folder etc and then installed a fresh copy of Firefox 4 (before installing addons): Still had the same issue.
    I have since installed addons to my Firefox and this site is apparently the only one where I have this issue.
    I am completely baffled as to why this specific site is taking so long to long (where it doesn't using other browsers and Firefox on other computers).
    Does anyone know what might be the issue?

    You're welcome.

  • When opening an InfoPath form InfoPath states "list does not exist" in production, opens fine in test. NaN issue with Auto Increment

    Hello all. I have an InfoPath form that opens from the test server fine. However, when I try to open it in Production I receive the following SOAP response.
    "The SOAP response indicates that an error occurred on the server:
    Server was unable to process request. ---> List does not exist.
    The page you selected contains a list that does not exist.  It may have been deleted by another user. ---> List does not exist.
    The page you selected contains a list that does not exist.  It may have been deleted by another user."
    I am trying to fix an auto generated form field for the web part that runs the my Project Management list. In test the increment by 1 works fine. I.E. "LEAD-2015-5". In Prod the list is returning NaN ( Not a Number ) for each project
    id. I.E. "LEAD-2015-NaN"
    The list is in Standard View when I edit the web part/page.
    Any help is much appreciated. As a developer I despise SharePoint, but I have to do what I have to do! :)

    Hello,
    If you are trying to get max item id from list then it returns "NaN" if there is no item. If you have items in prod list then open your form in IP designer and check the data connection. Make sure that all data connection links are referring to
    prod links.
    Also make sure that user is having at least read permission to that list to access data so verify this also.
    Let us know your result
    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • SQL execution does not change, but consistent read get higher

    Hi,
    Our SQL query execution does not change, but consistent reads get higher in our test enviroment but query looks fine in our development and production environments.
    In the Development instance the trace is:
    STAT #18446744071526492680 id=1 cnt=1 pid=0 pos=1 obj=7151 op='TABLE ACCESS BY INDEX ROWID MEMBER_CMS_SITE_ACCESS (cr=4 pr=0 pw=0 time=153 us cost=3 size=68 card=1)'
    STAT #18446744071526492680 id=2 cnt=1 pid=1 pos=1 obj=7152 op='INDEX UNIQUE SCAN MEMBER_SITE__MEMBERID_SITEID (cr=3 pr=0 pw=0 time=104 us cost=2 size=0 card=1)'
    So - we read 3 blocks from the index and then 1 from the table ( to make 4)
    In the Test instance the trace is:
    STAT #18446744071411593144 id=1 cnt=1 pid=0 pos=1 obj=7151 op='TABLE ACCESS BY INDEX ROWID MEMBER_CMS_SITE_ACCESS (cr=112 pr=0 pw=0 time=2820 us cost=3 size=70 card=1)'
    STAT #18446744071411593144 id=2 cnt=1 pid=1 pos=1 obj=7152 op='INDEX UNIQUE SCAN MEMBER_SITE__MEMBERID_SITEID (cr=3 pr=0 pw=0 time=90 us cost=2 size=0 card=1)'
    We read 3 blocks from the index but the table needs 109 more which cannot possibly be right.
    It looks like we are applying UNDO and those 109 are the work needed to do so.
    I have tried flushing the shared pool, and killing some sessions that could possibly be the cause... but with nothing in V$TRANSACTION
    I could understand this if there was a long-running transaction that's created a lot of dirty blocks, but there are no transactions at all... so it's not that.
    Thanks

    The SQL is very simple with only one predication in the where cluse and that is indexed,just like
    "select * from table where a=:b0"
    Column a is indexed. But ORACLE choose FTS not INDEX SCAN because of out-of-date stats maybe.
    So I updated the stats expecting to see ORACLE will choose INDEX SCAN. The fact is that ORACLE will not change existing FTS to INDEX until I flush the entire share pool.That's the problem.

  • Slow query execution time

    Hi,
    I have a query which fetches around 100 records from a table which has approximately 30 million records. Unfortunately, I have to use the same table and can't go ahead with a new table.
    The query executes within a second from RapidSQL. The problem I'm facing is it takes more than 10 minutes when I run it through the Java application. It doesn't throw any exceptions, it executes properly.
    The query:
    SELECT aaa, bbb, SUM(ccc), SUM(ddd), etc
    FROM MyTable
    WHERE SomeDate= date_entered_by_user  AND SomeString IN ("aaa","bbb")
    GROUP BY aaa,bbbI have an existing clustered index on SomeDate and SomeString fields.
    To check I replaced the where clause with
    WHERE SomeDate= date_entered_by_user  AND SomeString = "aaa"No improvements.
    What could be the problem?
    Thank you,
    Lobo

    It's hard for me to see how a stored proc will address this problem. I don't think it changes anything. Can you explain? The problem is slow query execution time. One way to speed up the execution time inside the RDBMS is to streamline the internal operations inside the interpreter.
    When the engine receives a command to execute a SQL statement, it does a few things before actually executing the statement. These things take time. First, it checks to make sure there are no syntax errors in the SQL statement. Second, it checks to make sure all of the tables, columns and relationships "are in order." Third, it formulates an execution plan. This last step takes the most time out of the three. But, they all take time. The speed of these processes may vary from product to product.
    When you create a stored procedure in a RDBMS, the processes above occur when you create the procedure. Most importantly, once an execution plan is created it is stored and reused whenever the stored procedure is ran. So, whenever an application calls the stored procedure, the execution plan has already been created. The engine does not have to anaylze the SELECT|INSERT|UPDATE|DELETE statements and create the plan (over and over again).
    The stored execution plan will enable the engine to execute the query faster.
    />

  • Select running slow in prod but work fine in T-1

    We have a query which run very slow on production database it is taking around 7 min to run.
    While it is working fine on T-1 database which gets refreshed every night, here it takes around 3 seconds.
    both the os version and database versions are same.
    Database is also refreshed and have same data and statistics.
    please update what could be the reason?
    SELECT c.txt_master_claim_no "Master Claim No",
    c.num_serial_no "Serial No",
    TO_CHAR(c.dat_loss_date, 'dd / mm / yyyy') "Loss Date",
    d.departmentname "Line of Business",
    m.productname "Product",
    tab.stat "Status"
    FROM (SELECT t.num_claim_no, 'REPUDIATION' stat, num_update_no
    FROM gc_clm_gen_info t, gc_clm_os a
    WHERE t.num_update_no =
    (SELECT MAX(p.num_update_no)
    FROM gc_clm_gen_info p
    WHERE p.num_claim_no = t.num_claim_no)
    AND t.txt_claim_status = 'X'
    AND a.cur_os_amount = 0
    AND a.num_ac_year * 100 + a.num_ac_month =
    (select max(s.num_ac_year * 100 + s.num_ac_month)
    from gc_clm_os s
    where s.num_claim_no = a.num_claim_no)
    AND t.num_claim_no = a.num_claim_no
    UNION
    SELECT a.num_claim_no, 'DISBURSE' stat, num_update_no
    FROM gc_clm_os a, gc_clm_gen_info b
    WHERE a.cur_os_amount = 0
    AND a.num_ac_year * 100 + a.num_ac_month =
    (select max(s.num_ac_year * 100 + s.num_ac_month)
    from gc_clm_os s
    where s.num_claim_no = a.num_claim_no)
    AND b.num_update_no >
    (SELECT MAX(x.num_update_no)
    FROM gc_clm_gen_info x
    WHERE x.num_claim_no = b.num_claim_no
    AND x.txt_claim_status in ('F', 'X'))
    AND a.num_claim_no = b.num_claim_no
    UNION
    SELECT a.num_claim_no, 'DISBURSE' stat, num_update_no
    FROM gc_clm_os a, gc_clm_gen_info b
    WHERE a.cur_os_amount = 0
    AND a.num_ac_year * 100 + a.num_ac_month =
    (select max(s.num_ac_year * 100 + s.num_ac_month)
    from gc_clm_os s
    where s.num_claim_no = a.num_claim_no)
    AND b.num_update_no =
    (SELECT MAX(x.num_update_no)
    FROM gc_clm_gen_info x
    WHERE x.num_claim_no = b.num_claim_no)
    AND a.num_claim_no = b.num_claim_no
    And b.txt_claim_status = 'F'
    and not exists
    (select 1
    from gc_clm_payment_details p
    where p.num_claim_no = a.num_claim_no
    and p.txt_status in ('APPROVAL DUE', 'APPROVED'))
    ) tab,
    gc_clm_gen_info c,
    uw_product_master m,
    uw_department_master d
    WHERE tab.num_claim_no = c.num_claim_no
    AND c.num_update_no =
    (SELECT MAX(d.num_update_no)
    FROM gc_clm_gen_info d
    WHERE d.num_claim_no = c.num_claim_no)
    AND c.num_department_code = d.departmentcode
    AND m.productcode = c.num_product_code
    AND M.DEPARTMENTCODE=D.DEPARTMENTCODE
    AND c.txt_claim_status NOT IN ('O', 'S')
    AND c.num_update_no = tab.num_update_no
    AND c.num_claim_no not in
    (select p.num_claim_no
    from gc_clm_payment_details p, gc_clmmst_resource_type r
    where p.num_type_of_party = r.num_resource_type_cd
    and r.txt_loss_exp = 'E'
    and p.txt_status = 'APPROVAL DUE') and Upper(C.txt_master_claim_no) like '%C231110020345%' order by c.NUM_CLAIM_NO Desc;
    Edited by: user12195658 on Mar 24, 2011 7:27 AM

    from T-1 explain plan output is:
    Explain complete.
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 1 | 132 | | 5862 (4)|
    | 1 | SORT ORDER BY | | 1 | 132 | | 5862 (4)|
    | 2 | NESTED LOOPS | | 1 | 132 | | 5853 (4)|
    | 3 | NESTED LOOPS | | 1 | 97 | | 5852 (4)|
    | 4 | NESTED LOOPS | | 1 | 83 | | 5851 (4)|
    | 5 | VIEW | | 78 | 2574 | | 5617 (4)|
    | 6 | SORT UNIQUE | | 78 | 6992 | | 5617 (78)|
    | 7 | UNION-ALL | | | | | |
    | 8 | FILTER | | | | | |
    | 9 | HASH JOIN | | 29 | 1943 | | 1266 (5)|
    | 10 | HASH JOIN | | 2895 | 115K| | 584 (5)|
    | 11 | INDEX FAST FULL SCAN | IND_GC_CLM_GEN_INFO | 2437 | 43866 | | 353 (5)|
    | 12 | TABLE ACCESS FULL | GC_CLM_OS | 36517 | 820K| | 229 (4)|
    | 13 | VIEW | VW_SQ_1 | 43391 | 1101K| | 680 (4)|
    | 14 | HASH GROUP BY | | 43391 | 1313K| 4712K| 680 (4)|
    | 15 | TABLE ACCESS FULL | GC_CLM_OS | 65293 | 1976K| | 228 (4)|
    | 16 | SORT AGGREGATE | | 1 | 15 | | |
    | 17 | INDEX RANGE SCAN | IND_GC_CLM_GEN_INFO | 6 | 90 | | 3 (0)|
    | 18 | HASH JOIN | | 76 | 6840 | | 2001 (5)|
    | 19 | HASH JOIN | | 2207 | 137K| | 1338 (5)|
    | 20 | HASH JOIN | | 365 | 17885 | 1256K| 1054 (4)|
    | 21 | TABLE ACCESS FULL | GC_CLM_OS | 36517 | 820K| | 229 (4)|
    | 22 | VIEW | VW_SQ_2 | 43391 | 1101K| | 680 (4)|
    | 23 | HASH GROUP BY | | 43391 | 1313K| 4712K| 680 (4)|
    | 24 | TABLE ACCESS FULL | GC_CLM_OS | 65293 | 1976K| | 228 (4)|
    | 25 | INDEX FAST FULL SCAN | PK_GC_CLM_GEN_INFO | 262K| 3849K| | 276 (5)|
    | 26 | VIEW | VW_SQ_3 | 30152 | 765K| | 661 (5)|
    | 27 | HASH GROUP BY | | 30152 | 883K| 3336K| 661 (5)|
    | 28 | INDEX FAST FULL SCAN | IND_GC_CLM_GEN_INFO | 46690 | 1367K| | 356 (6)|
    | 29 | FILTER | | | | | |
    | 30 | HASH JOIN | | 511 | 43435 | | 1535 (5)|
    | 31 | HASH JOIN ANTI | | 337 | 22579 | | 1180 (4)|
    | 32 | HASH JOIN | | 365 | 17885 | 1256K| 1054 (4)|
    | 33 | TABLE ACCESS FULL | GC_CLM_OS | 36517 | 820K| | 229 (4)|
    | 34 | VIEW | VW_SQ_4 | 43391 | 1101K| | 680 (4)|
    | 35 | HASH GROUP BY | | 43391 | 1313K| 4712K| 680 (4)|
    | 36 | TABLE ACCESS FULL | GC_CLM_OS | 65293 | 1976K| | 228 (4)|
    | 37 | INDEX FAST FULL SCAN | IND_GC_CLM_PAYMENT_DETAILS | 2396 | 43128 | | 125 (6)|
    | 38 | INDEX FAST FULL SCAN | IND_GC_CLM_GEN_INFO | 44253 | 777K| | 354 (5)|
    | 39 | SORT AGGREGATE | | 1 | 15 | | |
    | 40 | INDEX RANGE SCAN | IND_GC_CLM_GEN_INFO | 6 | 90 | | 3 (0)|
    | 41 | TABLE ACCESS BY INDEX ROWID | GC_CLM_GEN_INFO | 1 | 50 | | 3 (0)|
    | 42 | INDEX RANGE SCAN | PK_GC_CLM_GEN_INFO | 1 | | | 2 (0)|
    | 43 | SORT AGGREGATE | | 1 | 15 | | |
    | 44 | INDEX RANGE SCAN | IND_GC_CLM_GEN_INFO | 6 | 90 | | 3 (0)|
    | 45 | NESTED LOOPS | | 1 | 26 | | 5 (0)|
    | 46 | TABLE ACCESS BY INDEX ROWID| GC_CLM_PAYMENT_DETAILS | 1 | 21 | | 4 (0)|
    | 47 | INDEX RANGE SCAN | IND_GC_CLM_PAYMENT_DETAILS | 1 | | | 3 (0)|
    | 48 | TABLE ACCESS BY INDEX ROWID| GC_CLMMST_RESOURCE_TYPE | 1 | 5 | | 1 (0)|
    | 49 | INDEX UNIQUE SCAN | PK_GC_CLMMST_RESOURCE_TYPE | 1 | | | 0 (0)|
    | 50 | INDEX RANGE SCAN | UW_DEPARTMENT_MASTER_INDX | 1 | 14 | | 1 (0)|
    | 51 | INDEX RANGE SCAN | IND_UW_PRODUCT_MASTER | 1 | 35 | | 1 (0)|
    Note
    - 'PLAN_TABLE' is old version
    61 rows selected.

  • Query with same explain-plan but slower in one env

    Hi there
    I have a stored procedure which is executed from a web application. It contains a query (insert-select-from statement). When this stored procedure is called by the web application in PROD, it takes 13sec but it takes 19sec in TEST env. I checked the explain plan for this insert statement in both instances and it is same (see below). Actually, the cost is lower in TEST env.
    ENV: Oracle 10gR2 EE, on ASM - RHEL 64bit
    The TEST server is on a better/faster hardware and will become the new PROD in near future (faster and 16 CPUs  vs 8 in PROD, high performance SAN, 132GB RAM vs 96GB in PROD, etc). The TEST database has exact same init parameter and version/patch level as current PROD. So the application is being tested against it at the moment.
    Here are the explain-plans from both environments:
    From PROD Server
    Plan
    INSERT STATEMENT ALL_ROWS Cost: 143 Bytes: 696 Cardinality: 3
    18 SORT ORDER BY Cost: 143 Bytes: 696 Cardinality: 3
    17 HASH UNIQUE Cost: 142 Bytes: 696 Cardinality: 3
    16 WINDOW SORT Cost: 143 Bytes: 696 Cardinality: 3
    15 HASH JOIN Cost: 141 Bytes: 696 Cardinality: 3
    13 HASH JOIN Cost: 128 Bytes: 519 Cardinality: 3
    11 TABLE ACCESS BY INDEX ROWID TABLE MKTG.SATDATAIMPORT Cost: 125 Bytes: 1,728 Cardinality: 12
    10 NESTED LOOPS Cost: 125 Bytes: 1,992 Cardinality: 12
    3 HASH JOIN Cost: 5 Bytes: 22 Cardinality: 1
    1 TABLE ACCESS FULL TABLE MKTG.TMPG_CLICKS_HDGS Cost: 2 Bytes: 12 Cardinality: 1
    2 TABLE ACCESS FULL TABLE MKTG.TMPG_CLICKS_DIRS Cost: 2 Bytes: 10 Cardinality: 1
    9 BITMAP CONVERSION TO ROWIDS
    8 BITMAP AND
    5 BITMAP CONVERSION FROM ROWIDS
    4 INDEX RANGE SCAN INDEX MKTG.SATDATAIMPORT_HEADINGNO Cost: 19 Cardinality: 4,920
    7 BITMAP CONVERSION FROM ROWIDS
    6 INDEX RANGE SCAN INDEX MKTG.SATDATAIMPORT_DIRNO Cost: 89 Cardinality: 4,920
    12 TABLE ACCESS FULL TABLE MKTG.MONTHS12 Cost: 2 Bytes: 84 Cardinality: 12
    14 TABLE ACCESS FULL TABLE MKTG.REF_WEST_CATEGORY Cost: 12 Bytes: 191,809 Cardinality: 3,251
    From TEST Server
    Plan
    INSERT STATEMENT ALL_ROWS Cost: 107 Bytes: 232 Cardinality: 1
    18 SORT ORDER BY Cost: 107 Bytes: 232 Cardinality: 1
    17 HASH UNIQUE Cost: 106 Bytes: 232 Cardinality: 1
    16 WINDOW SORT Cost: 107 Bytes: 232 Cardinality: 1
    15 HASH JOIN Cost: 105 Bytes: 232 Cardinality: 1
    13 HASH JOIN Cost: 93 Bytes: 173 Cardinality: 1
    11 TABLE ACCESS BY INDEX ROWID TABLE MKTG.SATDATAIMPORT Cost: 89 Bytes: 864 Cardinality: 6
    10 NESTED LOOPS Cost: 89 Bytes: 996 Cardinality: 6
    3 HASH JOIN Cost: 7 Bytes: 22 Cardinality: 1
    1 TABLE ACCESS FULL TABLE MKTG.TMPG_CLICKS_HDGS Cost: 3 Bytes: 12 Cardinality: 1
    2 TABLE ACCESS FULL TABLE MKTG.TMPG_CLICKS_DIRS Cost: 3 Bytes: 10 Cardinality: 1
    9 BITMAP CONVERSION TO ROWIDS
    8 BITMAP AND
    5 BITMAP CONVERSION FROM ROWIDS
    4 INDEX RANGE SCAN INDEX MKTG.SATDATAIMPORT_HEADINGNO Cost: 9 Cardinality: 2,977
    7 BITMAP CONVERSION FROM ROWIDS
    6 INDEX RANGE SCAN INDEX MKTG.SATDATAIMPORT_DIRNO Cost: 59 Cardinality: 2,977
    12 TABLE ACCESS FULL TABLE MKTG.MONTHS12 Cost: 3 Bytes: 84 Cardinality: 12
    14 TABLE ACCESS FULL TABLE MKTG.REF_WEST_CATEGORY Cost: 12 Bytes: 191,868 Cardinality: 3,252
    What else can I check to find out why the query is slower in TEST env?
    Please advise.
    Best regards

    Here is some more info. The query is below:
    select distinct dr.line_num 
                     ,row_number() over (partition by di.HEADINGNO,di.DIRECTORYNO order by reportyear,to_number(di.monthno)) monthposition
                     ,di.SATID,di.REPORTYEAR,di.MONTHNO,di.MONTHEN,di.MONTHFR,di.HEADINGNO,hn.NAME_EN,hn.NAME_FR,di.DIRECTORYNO
                     ,di.SUPERDIRECTORYNO,di.PRINTDIRCODE,di.DIRECTORYNAME,round(to_number(di.IMPTTOTAL)) imptotal
                     ,round(to_number(di.IMPBEST)) impbest ,round(to_number(di.IMPTAVERAGE)) imptaverage
                     ,round(to_number(di.CLICKTOTAL)) clicktotal,round(to_number(di.CLICKBEST)) clickbest
                     ,round(to_number(di.CLICKAVERAGE)) clickaverage
                     ,round(avg(to_number(impttotal)) over(partition by di.HEADINGNO,di.DIRECTORYNO)) avgimp
               from satdataimport di,tmpg_clicks_hdgs hd,tmpg_clicks_dirs dr, months12 m12, ref_west_category hn
               where di.headingno   = hd.id
                 and di.directoryno = dr.id
                 and dr.line_num=hd.line_num
                 and di.reportyear  = m12.year
                 and di.monthno     = m12.month
                 and hn.CATEGORY_CODE = di.headingno
               order by di.headingno, di.directoryno,di.reportyear,to_number(di.monthno)
    The largest table is "satdataimport" in the query has "12274818" rows. Rest of the tables are very small containing few rows to less than 4000 rows.
    I have refreshed the statistics of the larger table but this did not help either. Even a simple query like "select count(*) from satdataimport" is taking 15sec in TEST while it takes 4Sec in PROD when I run it from TOAD.
    The other strange thing is that when I run this stored procedure from TOAD, it takes 200 milli sec to complete. There is a logging table to which the stored procedure records the elapsed time taken by this INSERT statement.
    Since this query is in a stored procedure being called from the web app, the QA team wants quicker response. Current PROD is faster.
    The tables have same indexes, etc and contain identical data as that in PROD (were refreshed from PROD yesterday).
    What else can I check?
    Best regards

  • Premiere elements 13 keeps asking me to connect to internet to register the product but my internet is fine. I have gone through the forum to get help but nothing is OK....

    Premiere elements 13 keeps asking me to connect to internet to register the product but my internet is fine. I have gone through the forum to get help (validation of internet, validation of the ability to access secure servers, the validity of the ceritificate....) but nothing is working for me. Would someone have additional info. to handle this situation ? Thanks

    Jean Lucd86932678 to confirm you completed the steps listed in Sign in, activation, or connection errors | CS5.5 and later?  If so what specific error messages are you receiving?

  • Oracle 11G - Oracle AWR query execution time in report

    I have used AWR tool of oracle 11G. I have exported query historical statistics of production databaser using awrextr.sql and then load the exported dump file using awrload.sql script.
    Then i used awrrpti.sql and awrsqrpi.sql for generating report of sql queries. Every thing is working fine and generated reports are also very helpful, but report does not show the exact time when the query was executed. How can i get the actual time when the query was executed ?
    any help please ?

    If you would have consulted the Oracle Reference Manual to get the view descriptions, you should have your question is a rhetorical one with the answer NO.
    This is because every statement can be executed one or more times, and Oracle would need to keep track of all individual executions.
    I do agree most 'applications' do not use bind variables, and consequently only have unique statements, but Oracle didn't take that into account, and rightly so.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for