Confusion between the performance problem with a query

I have a query that takes 3 minutes (according to another developer, but when I run it not even returned after 10 minutes) to return lines nil. But the interesting part is that instead of select * if I give a count (*) select, he returned in less than a second. And even the subquery returns no rows in less than one second. The query is as follows. I see no option to answer this confusing behavior. Please suggest me an option I can verify, what explains this scenario. I am interested to know the root cause of it. Please let me know if you need any details.
select * from order_lines_flmnt_stg_in ol
 WHERE order_lines_flmnt_stg_in_id IN (
          SELECT DISTINCT order_lines_flmnt_stg_in_id
                     FROM order_lines_flmnt_stg_in ol,
                          order_header_flmnt_stg_in oh,
                          order_lines oln
                    WHERE ol.TYPE = 'Original'
                      AND ol.item_code NOT IN (
                             SELECT oln.item_code
                               FROM order_lines oln,
                                    order_lines_flmnt_stg_in ol,
                                    order_header_flmnt_stg_in oh
                              WHERE oh.po_id = ol.po_id
                                AND ol.item_code = oln.item_code)
                      AND (    ol.error_message IS NULL
                           AND oh.error_message IS NULL
                           AND oh.activate_flag = 1
                          ));
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Sep 30 16:41:53 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> set lines 10000
SQL> alter session set current_schema = epix;

Session altered.

SQL> set timing on
SQL>           SELECT DISTINCT order_lines_flmnt_stg_in_id
  2                       FROM order_lines_flmnt_stg_in ol,
  3                            order_header_flmnt_stg_in oh,
  4                            order_lines oln
  5                      WHERE ol.TYPE = 'Original'
  6                        AND ol.item_code NOT IN (
  7                               SELECT oln.item_code
  8                                 FROM order_lines oln,
  9                                      order_lines_flmnt_stg_in ol,
 10                                      order_header_flmnt_stg_in oh
 11                                WHERE oh.po_id = ol.po_id
 12                                  AND ol.item_code = oln.item_code)
 13                        AND (    ol.error_message IS NULL
 14                             AND oh.error_message IS NULL
 15                             AND oh.activate_flag = 1
 16                            );

no rows selected

Elapsed: 00:00:00.11
SQL> select count(*) from order_lines_flmnt_stg_in ol
  2   WHERE order_lines_flmnt_stg_in_id IN (
  3            SELECT DISTINCT order_lines_flmnt_stg_in_id
  4                       FROM order_lines_flmnt_stg_in ol,
  5                            order_header_flmnt_stg_in oh,
  6                            order_lines oln
  7                      WHERE ol.TYPE = 'Original'
  8                        AND ol.item_code NOT IN (
  9                               SELECT oln.item_code
 10                                 FROM order_lines oln,
 11                                      order_lines_flmnt_stg_in ol,
 12                                      order_header_flmnt_stg_in oh
 13                                WHERE oh.po_id = ol.po_id
 14                                  AND ol.item_code = oln.item_code)
 15                        AND (    ol.error_message IS NULL
 16                             AND oh.error_message IS NULL
 17                             AND oh.activate_flag = 1
 18                            ));

  COUNT(*)
----------
         0

Elapsed: 00:00:00.18
SQL> select count(*) from order_lines_flmnt_stg_in;

  COUNT(*)
----------
      3198

Elapsed: 00:00:00.18
SQL> 
I don't know if it's relevant, but there are no locks on the tables involved.

Published by: release 6' - 8 "September 30, 2009 16:49

count (*) SELECT can use the index only without having to consult the table at all...
Amiel

Tags: Database

Similar Questions

  • I just bought an IPhone 6 Plus. When I get a text Message I get no advice or vibrations. I have all the settings correct. I know many others with the same problem with this phone. Any suggestions?

    I have just purchased IPhone 6 Plus. When I get a text Message I get no notification - no vibration and no noise. I put everything correctly. I know several others who have the same problems with this phone. Any suggestions?

    I have the same problem. You own an iPhone 6 Plus 2/9. Problems began the next day. Phone took over and got another new. Problems with another brand new! Volume is also impoverished - even when up until the end. Extremely frustrated! Any advice would be appreciated.

  • I am also having the same problem with the same updates. I have Windows XP SP3 and it's updates with the problem.

    I am also having the same problem with the same updates. I have Windows XP SP3 and it's updates with the problem.

    Security Update for Microsoft .NET Framework 2.0 SP2 on Windows Server 2003 and Windows XP x 86 (KB2572073)
    A security update for .NET Framework 2.0 SP2 and 3.5 SP1 on Windows Server 2003 and Windows XP x 86 (KB2518864)
    Security Update for Microsoft .NET Framework 2.0 SP2 on Windows Server 2003 and Windows XP x 86 (KB2633880)

    They all install properly but switches back to windows update to install. It's some kind of loop.

    Hi billy73,

    In addition, if you still have questions, please take a look at the thread similar here with a solution as possible.

    I hope this helps!

  • I saw the problem with Windows Live Mail gel but I have the same problem with Windows Mail.

    I saw the problem posted on Windows Live Mail gel but I have the same problem with Windows Mail. Sometimes, while mouse refuses I can scroll vertically with the keyboard, but not always... I changed to another wireless mouse, and this has not changed. I run Vista and can't find the update, that you reference. The reopening and closing program usually fixes it, but it's annoying. It happened for about 6 weeks or so.

    Can anyone help?

    I run Vista and can't find the update, that you reference.

    What update WHO refers to?

    Try to compact and repair the database.

    WMUtil
    http://www.oehelp.com/WMUtil/default.aspx

    And search for malware with the free version of this tool.

    Malwarebytes Anti-Malware
    http://www.Malwarebytes.org/MBAM.php

  • LR and PS will not update 'Download error' 49 customer service contact? anyone had this problem and how to solve? was running windows 8.1 and now running windows 10 but had the same problem with two BONES

    LR and PS will not update 'Download error' 49 customer service contact? anyone had this problem and how to solve? was running windows 8.1 and now running windows 10 but had the same problem with two BONES

    Check your hosts file.  to help with this and more:

    Log, activation, or connection errors. CS5.5 and later, Acrobat DC

  • Navigation in both sense between the anchor points with "prev" and "next buttons?"

    Hi all

    I'm working on a horizontal presentation site that has anchors on each part. That the user scroll, he snaps to each anchor point. It works fine with just the mouse wheel, but I wish I had previous buttons and following which allow easy navigation between points. I know I can have buttons to jump to say on each article has > B > C and then C > B >, but it's a simple "prev" and "next" buttons that are pinned to the page as a whole. Then, as the page scrolls from left to right, the buttons remain in place. Is it possible to have them just go to previous and next in the line, rather than linking a button to anchor point A, B, C, etc.?

    NEW WIDGET! Navigation in both sense between the anchor points with "prev" and "next" buttons http://goo.GL/TMbZRc

  • Cannot get CF11 to download the free trial version for students.  Anyone having the same problem with the Adobe site?

    Cannot get CF11 to download the free trial version for students.  Anyone having the same problem with the Adobe site?

    Hello

    Please download from http://www.adobe.com/cfusion/tdrc/index.cfm?product=coldfusion&promoid=DJDUK use your Adobe ID and password to login and download CF11.

    Let me know in the case where you are facing any problems during the download, if you get any error try another browser.

    Thank you

    Priyank

  • Troubleshooting performance problems with the mail server on the virtual computer

    I have a virtual machine with a mail server installed on a windows OS. But all of a sudden, my clients on the server response times decreased significantly.

    This could be the cause of this problem?
    It could be to do with the network, storage, or resources, but I don't know what steps I could take to determine fault

    Would someone mind helping me with the steps I could take to solve this problem?

    Thank you

    The below document page 20 and 21 accurate meters, you should look at the virtual machine level.

    http://www.VMware.com/files/PDF/Exchange_2010_on_VMware_-_Best_Practices_Guide.PDF

    These counters can be used for any virtual computer not only Exchange.  If you are familiar with ESXTOPs I believe that the best way to deep dive in the diagnosis of performance problems.  Also here is a link for these parameters.

    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalID=1008205

    This link takes you to http://communities.vmware.com/docs/DOC-9279 which has the description on the stats.

  • What is the problem with this query? My head is numb!

    Can someone tell me why this request;

    < cfquery datasource = "manna_premier" name = "qGetstats" >
    SELECT the user name,
    UserFirstName,
    UserLastName,
    LastLogin,
    TotalLogins,
    UserZone,
    TM_Name
    USERS
    WHERE UserID = ' #. TM_log UserID # '.
    < / cfquery >

    generates this error message;

    Run database query error.

    [Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] Too few parameters. 1 expected.
    The error occurred in D:\Inetpub\mannapremier\TM_log_report2.cfm: line 28
    26 :         TM_Name
    27 : FROM Users
    28 : WHERE UserID = "#TM_log.UserID#"
    29 : </cfquery>
    30 : 
    

    SQLSTATE07002
    SQLSELECT the user ID, UserFirstName UserLastName, LastLogin, TotalLogins, UserZone, TM_Name FROM USERS WHERE UserID = '10120.
    VENDORERRORCODE-3010
    DATASOURCEmanna_premier

    I see that my variable WHERE comes through but the domain name is not working. I'm sure that the answer is obvious, but it drives me crazy!

    Help, please!

    I tried and got this result;

    No, you now use different data. Now, the user ID is empty, while she was 10120 first.

    The only problem seems to be double quotes. To check this, test with

    WHERE UserID = 10120
    

    I'm assuming that the userID field to be an integer. If it is text, then use single quotes (not!), as in

    WHERE UserID = '#TM_log.UserID#'
    
  • What is the problem with this query?

    Hello

    I need some advice on how to change the following query (with perhaps some analytical function) to speed it up. Currently, it takes 6 + minutes. This query is executed in response to a request from the front-end application and 6 + min is certainly unacceptable.

    I am trying to provide as much information I can think, but if more information is needed, please let me know.

    I have a table called "wave_result". It contains millions of rows. PK is Wave_Id, Version_nbr, node_nbr and prod_nbr. For each 'wave_id + node_NBR + prod_nbr' there are several versions (version_nbr). In the following query, I try to extract a line with MAX version_nbr for combination of ' wave_id + node_NBR + prod_nbr.

    H3. Request:
    SELECT ip1.fnln_cat,
                ip1.sub_cat,
                ip1.bus_cat,
                NVL (SUM (ip1.lsu), 0) val
        FROM ideal_prod ip1, ideal_store s, wave_result wr
       WHERE  wr.wave_id = 51
             AND wr.prod_nbr = ip1.prod_nbr
             AND wr.wave_id = ip1.wave_id
             AND wr.version_nbr =
                    (SELECT MAX (wr1.version_nbr)
                       FROM wave_result wr1
                      WHERE   wr1.wave_id = wr.wave_id
                            AND wr1.node_nbr = wr.node_nbr
                            AND wr1.prod_nbr = wr.prod_nbr)
             AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
             AND s.wave_id = wr.wave_id
             AND s.node_nbr = wr.node_nbr 
    GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat
    H3. Rank of charges:
    ========
    "wave_result" is the largest table with millions of rows.
    Table                Total Rows       Rows for wave_id = 51
    Ideal_prod           188K             38K
    Ideal_store          3K               574
    Wave_result          90M              19M
    H3. Stats
    are updated almost daily by the DBA (not sure if that's a good or bad).

    H3. Explain the Plan:
    =========
    SELECT STATEMENT ALL_ROWS Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
         12 HASH GROUP BY Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
              11 VIEW VIEW SYS.VM_NWVW_2 Cost: 330,737 Bytes: 401,787 Cardinality: 14,881 
                   10 FILTER 
                        9 HASH GROUP BY Cost: 330,737 Bytes: 2,425,603 Cardinality: 14,881 
                             8 HASH JOIN Cost: 327,183 Bytes: 41,233,784 Cardinality: 252,968 
                                  1 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKIDEAL_STORE Cost: 4 Bytes: 13,202 Cardinality: 574 
                                  7 HASH JOIN Cost: 327,178 Bytes: 35,415,520 Cardinality: 252,968 
                                       5 HASH JOIN Cost: 198,619 Bytes: 18,764,328 Cardinality: 183,964 
                                            3 TABLE ACCESS BY INDEX ROWID TABLE APAPOPR.IDEAL_PROD Cost: 939 Bytes: 2,272,380 Cardinality: 37,873 
                                            4 TABLE ACCESS FULL TABLE APAPOPR.WAVE_RESULT Cost: 197,063 Bytes: 7,974,414 Cardinality: 189,867 
                                       6 INDEX RANGE SCAN INDEX (UNIQUE) APAPOPR.XPKWAVE_RESULT Cost: 82,467 Bytes: 721,495,854 Cardinality: 18,986,733 
    H3. Sample data:
    ===========
       For wave_id = 51
                     there are 28466854 rows in "wave_result" table
    
       For wave_id = 51 and node_nbr = '0201' and  prod_nbr = '0226960'
                     there are 3 rows in "wave_result" table
    H3. Version of database information are below to:
    =========================
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE            11.1.0.7.0                        Production
    TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Thank you very much!!

    Concerning
    For wave_id = 51
                     there are 28466854 rows in "wave_result" table
    
       For wave_id = 51 and node_nbr = '0201' and  prod_nbr = '0226960'
                     there are 3 rows in "wave_result" table
    

    As you mentioned that this particular request is called by a front screen, how different search criteria you get it to show on the front end?
    Assuming that if the user is searching just of wave_id = 51 which lines returns to 28466854, it is certainly not a good approach to go look up many records to put end Front end is very light and can not hold many records and will be finally the web server will throw off out of memory exception. Always a limit on the number of records that you retrieve from the database and display it on the front plane.
    OR
    The second case where the user makes a search by wave_id, node_nbr and prod_nbr, even if she returns to 3 lines, behind the scens, he still made a full scan on the wave_result table. If we go with analytical function, we can reduce a sweep of extra table on the wave_result table. Also the table has millions of lines and the max (version_nbr) seems to be a frequently used on this table sub query. While inserting a record into the table wave_result, you must probably have a calculated value that will tell you its value max and you will choose just the rank of this value, instead of at each time max(). something like below...

    SELECT ip1.fnln_cat,
                ip1.sub_cat,
                ip1.bus_cat,
                NVL (SUM (ip1.lsu), 0) val
        FROM ideal_prod ip1, ideal_store s, wave_result wr
       WHERE ipl.wave_id = 51
             AND wr.prod_nbr = ip1.prod_nbr
             AND wr.wave_id = ip1.wave_id
             AND wr.wave_id = s.wave_id
             AND wr.node_nbr = s.node_nbr
             AND wr.precomputed_max_value = 'MAX'
             AND NVL (wr.ovrd_dcsn_nm, wr.dcsn_nm) = 'Add'
    GROUP BY ip1.fnln_cat, ip1.sub_cat, ip1.bus_cat;
    
  • Confusion between the query

    Hi friends


    I use oracle 8i and I will try the following


    Logically in my software day starts at 04:00 and ends at 03:59 the next day


    so need a query that returns the hours passed since today morning 4 AM until now. I'm only using sysdate at the moment, but there is a twist since date starts at 04:00 and not at 12 AM @ 12 h I have hours including hours of the previous day until 03:59

    at 12:20 hours
    at 1:21 hours

    I mentioned the following queries but without success
    select (to_date(trunc(sysdate) || ' 04:00:00','dd-mon-yy hh24:mi:ss') -  to_date(trunc(sysdate),'dd-mon-yy hh24:mi:ss'))*24 from dual
    select (sysdate+4/24 - sysdate) * 24 from dual;
    Any help would be appreciated

    Concerning
    Park

    Published by: Park February 11, 2011 01:56

    The difference between the time so you have to current system and last time from 04:00.

    The time difference in days is:

    (SYSDATE-(TRUNC(SYSDATE-4/24)+4/24))
    

    Within hours, it is:

    24*(SYSDATE-(TRUNC(SYSDATE-4/24)+4/24))
    
  • &gt;: everyone is having the same problem with all the days that I have now with the update on thursda after update, it could not be started "could not find xpcom" restored Dáil

    with the update of daily Thursday (Australia) after update owned couldn't boot received message "could not find xpcom.
    I then restored by day sauvegardΘ installed upgrading again every day would not restart with the same message
    I tried again on Saturday you have the same problem
    I'm now ignoring the update message that is very annoying because he wants me to update daily

    The bug in question should be solved with a daily update of today. However, I agree with the recommendation to go with 31.0 once it comes out next Tuesday, or at least to use the beta versions (once per cycle) as a compromise between stability and get the latest features and updates to the platform.

  • Confusion between the Satellite A200-13O and A100-784

    Hello...

    Please can you help me decide which laptop I will buy.

    The concern here is the difference in performance between the "GMA 950 up to 256' in the A200 and the" 128 "in up to the A100.". "

    Is there a significant difference in performance (all game), or it's like the same.
    Because if there is little or no difference in performance, I'll go for the cheaper A100.

    Thank you.

    Hey Buddy,

    There is no huge difference, so if you take the A100 you get quite the same performance as on A200.

    I have an A100 with XP and it works well for me. For example: prey runs very nice and the machine does its job.

    Hope I could tell you because your question to which machine is best for you.

    Welcome them

  • Structure of the event: problem with data transfer

    Hello everyone,

    for three days I'm troubleshooting an issue in LabView with the event structures. I really hope someone can help here, because I can't find anything on the entire WEB.

    I had six groups of equal to a VI entry, each containing five checks enum (among others) where the user can specify some configuration of measurement data. I want the program to do is: to recognize if a any of these enum values has been changed and if yes, then submit the values containing the cluster in a subvi then calculates the wiring and affect the material of the ports. In addition, i need to submit the number of the enum element that was changed, so the program is able to clear the user input in the case of a breach (e.g. If the user sets two entries of enum control 1 meter and 2 Group 1 and then tries to set a third counter of entry to port 3, the program displays a message and deletes third entry as the number of entries of counter is limited to 2 per cluster).

    To resolve this problem, I used a structure of the event with 6 x 5 cases (change of enum value 1 Group 1 Group 1 enum value 2 change... and so on until the change in the value enum 5 Group 6).

    The problem is that if the user changes a value, the event structure reacts and performs the proper case; However VALUES of the cluster, the user changed are not subject to the SECOND time that an event occurs. It is a kind of a situation, "n-1". For example, if all five controls Enum of Group 1 are 'disabled' first and the user sets enum 3 of 'Meter entry', the structure of the event runs but submits the values previous to the Subvi (all enums 'Disabled'). When the user makes the second change, say that enum SWITCH1 to "Analog Input", the structure of the event is running again and passes the values of the FIRST user to the Subvi editing, then the Subvi gets data "enum 3 meter inlet and all other disabled enumerations.

    In easier words: if I have new values on my cluster "Kanal 1" (left side of the screenshot) and run the structure of the event, on the right side to "Kanal 1" indicator, I get the previous values (n-1).

    The structure of my event is in a while loop. If I create a timeout every 10 ms, and a loop of 250 ms the waiting time, I got the 80% chance that the recent changes are transferred to the Subvi correctly, in other cases I have a delay of the 1 step as described above. It seems to be directly based on the time that I specify the while to wait - but I can't explain it and I cannot accept a less than 100% chance to transfer the correct data, nor can I accept delays of a few seconds for each loop run. If I indicate timeout (infinite) get delayed 1-1 step values in all cases.

    When I specify cases of event to react on "all items value change" of the structure of the event behaves properly - but then I can't handle indicate which element has changed, as the CtlRef of output in case of a structure does not specify "enum 1, enum 2..." but only "Group 1".

    Does anyone have a solution to this? It is certainly a problem with the structure of the event, but I can't understand what to change.

    Thank you much in advance,

    Mr. Boiger

    This is because the terminal is read until the structure of the event runs.   Terminal is read, the event structure is waiting for an event.  The change in value.  Business events are running, but the value is the old value.

    Put the terminal inside the event.

    Or, you can display the connector called "New value" on the side left (stretching down from the border of the node 'CtrRef').  Use a wire one to come.

  • FSX and FSX acceleration not will not activate after the uninstallation and reinstallation of the following problems with Windows 7 upgrade

    After the upgrade to Windows Vista Ultimate SP2 Windows 7, I couldn't FSX to load.  It would hang at the splash screen.  This has since been resolved and may have been a conflict between my card graphic and sound card and maybe even my webcam.  I then tried to reinstall FSX.  However, I decided to load up the Accerleration as before, but when I entered the activation code it says after trying that he could not get an answer to the server and to verify that I had an internet session active.  I did, but he always refused to activate.  So I uninstalled FSX acceleration and ran repair on FSX.  But now, he wants the activation code for FSX and when I write this so I always get the message that it cannot get a response from the server, please try again later or check that your internet connection is active.  I have the full internet connection, but doesn't understand why it won't save my activation codes.  I am limited to 30 minutes and cannot be installed acceleration as it wants the code for FSX.  I read on the forum that you can uninstall and reinstall on the same computer as many times you like then why used enable it?  It seems that he doesn't like my internet connection even though I am on the internet.  Anyone has any ideas. My pc is a Dell Inspiron 530 s with Nvidia 9400Gt card and card Soundblaster with 160 gb 1.66 ghz, 4gig ram and router Netgear WGR614 cable wireless

    Hi steve, I managed to install in the end.  I upgraded to a hard drive more that I wanted more space and copied the image to the new drive.  FSX is not yet accept the keys during the installation.  I ran the above utilities (see blog Amritas) to clear the license keys, empty temporary folders and change the registry entry by using 'regedit' on the command line, but still his wouldn't.  In the end, I installed and uninstalled three times until I finally installed it on a partition on the drive and he finally accepted the license keys.  This was done on the original admin user account that I had problems with from the start.  I have now it works.  The utility I used was KB928080 Microsoft.   I can only suggest you keep trying or partition of your hard drive and try and install on the new partition after erasing the license keys and temp folders (see above Amrita).  I can't guarantee that it works well.  To me it's a question of licenses i.e. acceleration has been uninstalled and reinstalled many times so it will no longer accept the license keys.  Happy installing! I don't know how is it frustrating.

Maybe you are looking for