Query current AC adapter

The wire of my adapter became tired between the adapter and the computer - I ordered a new one, but instead of 15V and 8A (for a Satellite A40) its 15V and 10A - the provider says its Ok but I won't burn my baby's brains! Can someone reassure me?

Thank you

Donald

Hello

Your Satellite must certainly 15V 8A 120W adapter PA3237U-1ACA part number.
Try to order the original part.

Tags: Toshiba

Similar Questions

  • currently connected adapter is not supported. system will continue on battery

    currently connected adapter is not supported. system will continue on battery

    BIOS is a newer A12. try to drain, but same problem. tried a different wall jack, same problem

    I don't have the battery connected more since its broken. I tried a different power adapter and its giving the same error. It only happens when I play games, meaning when it requires more power then my FPS fall and I can't play the game anymore. I think that its my motherboard. Help, please.

    Solved the problem. I swapped the video card in my m17x r4 (7970 m) friends

    No error message, no more FPS drop, reinstall the FANS.

  • Update for hp pavilion g6-1d73us WiFi adapter

    I have a HP Pavilion g6-1d73us running Windows 7 Home Premium with Intel Core i3 2.30 GHz, 4 GB RAM, 64-bit OS and want to upgrade my wireless WiFi 802.11ac 802.11n wifi adapter so I can also change my modem & router to the new, faster standard. The current wifi adapter I have is Realtek RTL8188CE 802.11 b/g/n wifi adapt. I studied the material on the internet and I think I want an Intel Wireless AC 7260 wifi adapter, but I don't know if it is compatible with my laptop. Could you please tell me what 802.11ac wireless card or adapter is compatible with my laptop or if I'm even able to upgrade that component. My computer works fine and has no problem. Thank you.

    Sorry no. The computer HP laptop motherboard has a BIOS program that is configured to stop the boot process, if all the wireless but very specific cards is installed. In the case of your laptop, no adapter 802.11ac lies on the 'white list' to boot.

    Do not shoot the Messenger.

    If it's 'the Answer' please click on 'Accept as Solution' to help others find it.

  • Components of black 10 loose adapter.

    Hello

    My adapter recently started to make noise when I shake the adapter, which, inside, it resembles a component that is loose and it feels big and heavy. His work yet but is it desirable to continue using the power adapter or do I have to replace the current power adapter or is there a way that I can do about it? Please advice.

    Thank you.

    You must change the adapter, because nobody knows what type of component, it is, and what might happen with her...

    Then to be sure, change

  • ENVY of HP TouchSmart m6-k025dx: Wireless adapter m6-k025dx Upgrade

    I wanted to update my adapter dual band wireless. There is a dual band wireless adapters that are compatible with my laptop? If so, which do you recommend? My current wireless adapter is Intel Centrino Wireless - N 2230.

    Hello

    There is a list of cards wireless on the maintenance and Service Guide from the following link:

    http://support.HP.com/us-en/product/HP-envy-M6-Sleekbook/5375391/model/5447426/manuals/

    Good luck

  • SDO_RELATE within PL/SQL query with rownum clause runs slowly on 12 c - works great on 10 g

    Hello

    I use the database 12.1.0.2 with a node 2 RAC on Windows.

    I am struck by a really weird performance problem with a particular query.  Bear with me while I try to explain...

    I have a chart with lines 30 sdo_geometry million, in 7 partitions with a local partitioned spatial index divided.  Called BIG_PARTITIONED_TABLE for this example.

    I query the table to search for one line with a geometry that is equal to the geometry of my request.  In this case I use sdo_relate with "mask = equal".  Instantly returns:

    SQL> select id, geometry
      2  from       BIG_PARTITIONED_TABLE o
      3  where      sdo_relate(o.geometry, sdo_geometry(2002, 2157, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
      4     SDO_ORDINATE_ARRAY(604853.595, 692379.864, 604879.046, 692350.272)), 'mask=equal') = 'TRUE'
      5  and rownum = 1;
    
            ID
    ----------
    GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    -------------------------------------------------------------------------------
    2.5405E+12
    SDO_GEOMETRY(2002, 2157, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(604853.595, 692379.864, 604879.046, 692350.272))
    
    Elapsed: 00:00:00.10
    
    

    But if I put the same query in PL/SQL, so it takes 21 seconds:

    SQL> declare
      2     l_id number;
      3     l_geom sdo_geometry;
      4     l_window_geom sdo_geometry;
      5  begin
      6     l_window_geom := sdo_geometry(2002, 2157, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
      7             SDO_ORDINATE_ARRAY(604853.595, 692379.864, 604879.046, 692350.272));
      8
      9     select id, geometry
    10     into l_id, l_geom
    11     from    BIG_PARTITIONED_TABLE o
    12     where   sdo_relate(o.geometry, l_window_geom, 'mask=equal') = 'TRUE'
    13     and rownum = 1;
    14
    15  end;
    16  /
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:21.13
    
    

    If I remove the "rownum = 1", then it returns instantly:

    SQL> declare
      2     l_id number;
      3     l_geom sdo_geometry;
      4     l_window_geom sdo_geometry;
      5  begin
      6     l_window_geom := sdo_geometry(2002, 2157, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
      7             SDO_ORDINATE_ARRAY(604853.595, 692379.864, 604879.046, 692350.272));
      8
      9     select id, geometry
    10     into l_id, l_geom
    11     from    BIG_PARTITIONED_TABLE o
    12     where   sdo_relate(o.geometry, l_window_geom, 'mask=equal') = 'TRUE';
    13
    14  end;
    15  /
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.03
    
    

    If using sdo_equal instead of sdo_relate and keep the "rownum = 1", then it returns instantly.

    SQL> declare
      2     l_id number;
      3     l_geom sdo_geometry;
      4     l_window_geom sdo_geometry;
      5  begin
      6     l_window_geom := sdo_geometry(2002, 2157, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1),
      7             SDO_ORDINATE_ARRAY(604853.595, 692379.864, 604879.046, 692350.272));
      8
      9     select id, geometry
    10     into l_id, l_geom
    11     from    BIG_PARTITIONED_TABLE o
    12     where   sdo_equal(o.geometry, l_window_geom) = 'TRUE'
    13     and rownum = 1;
    14
    15  end;
    16  /
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.13
    
    

    Here is a comparison of the plans to explain.  First, here's the good thing, that is using the spatial index (BIG_PARTITIONED_TABLE_SPIND):

    select id, GEOMETRY
    FROM
    BIG_PARTITIONED_TABLE O WHERE SDO_EQUAL(O.GEOMETRY, :B1 ) = 'TRUE'
    AND ROWNUM = 1
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.01       0.02          0         39          0           0
    Fetch        1      0.00       0.01          0         31          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        3      0.01       0.04          0         70          0           1
    
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 263     (recursive depth: 1)
    Number of plan statistics captured: 1
    
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
    ---------- ---------- ----------  ---------------------------------------------------
             1          1          1  COUNT STOPKEY (cr=99 pr=0 pw=0 time=43307 us)
             1          1          1   PARTITION RANGE ALL PARTITION: 1 7 (cr=99 pr=0 pw=0 time=43297 us cost=0 size=66 card=1)
             1          1          1    TABLE ACCESS BY LOCAL INDEX ROWID BIG_PARTITIONED_TABLE PARTITION: 1 7 (cr=99 pr=0 pw=0 time=43280 us cost=0 size=66 card=1)
             1          1          1     DOMAIN INDEX  BIG_PARTITIONED_TABLE_SPIND (cr=98 pr=0 pw=0 time=43250 us)
    
    

    Then the slow that does not use the spatial index.

    select id, GEOMETRY
    FROM
    BIG_PARTITIONED_TABLE O WHERE SDO_RELATE(O.GEOMETRY, :B1 , 'mask=equal') = 'TRUE'
      AND ROWNUM = 1
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.03       0.03          0       1123          0           0
    Fetch        1     24.25      24.25          0     499429          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        3     24.30      24.29          0     500552          0           1
    
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 263     (recursive depth: 1)
    Number of plan statistics captured: 1
    
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
    ---------- ---------- ----------  ---------------------------------------------------
             1          1          1  COUNT STOPKEY (cr=499532 pr=0 pw=0 time=24289612 us)
             1          1          1   HASH JOIN RIGHT SEMI (cr=499532 pr=0 pw=0 time=24289586 us cost=32 size=144 card=1)
             1          1          1    VIEW  VW_NSO_1 (cr=103 pr=0 pw=0 time=31110 us cost=29 size=98016 card=8168)
             1          1          1     COLLECTION ITERATOR PICKLER FETCH SDO_PQRY (cr=103 pr=0 pw=0 time=31104 us cost=29 size=16336 card=8168)
      16914892   16914892   16914892    PARTITION RANGE ALL PARTITION: 1 7 (cr=499429 pr=0 pw=0 time=28678375 us cost=3 size=6600 card=100)
      16914892   16914892   16914892     TABLE ACCESS FULL BIG_PARTITIONED_TABLE PARTITION: 1 7 (cr=499429 pr=0 pw=0 time=23406547 us cost=3 size=6600 card=100)
    
    

    I tried adding an indication / * + index (o BIG_PARTITIONED_TABLE_SPIND) * / but that did not help.

    I am struck this issue during testing of upgrade 10.2.0.5 to 12.1.0.2.  The query works perfectly on 10g - we note only that this question on 12 c.

    I can't use sdo_equal as the real mask that we want is equal + dommagescausdspar + covers.  I'm just using equal here to simplify the test.

    I use "rownum = 1" because I want to just the first result.  In practice I can rewrite probably is a FOR LOOP, I get out after the first result, but that seems all just awful.

    Any ideas?  If anyone has seen anything like this before?  Its an optimizer delivers really so I'm going to cross post the SQL Forum after a certain time, but thought I would post it here first.

    Thank you

    John

    Hi John,.

    Can you please try the following before your slow queries event?

    "ALTER session set events ' trace 54669 name context forever."

    Thank you

    Ying

  • Help setting up a SQL query with poor performance

    Hi all

    Database version: 10.2.0.5

    I'm working on a new report to view the top users by the number of calls. The table is truncated and filled again every month with records for the previous month; It contains approximately 400 000 records.

    I created a view with the columns needed for the report; also, the two functions of view calls to determine if a phone number is assigned to multiple staffs or several departments.

    It's full again table every month:

     CREATE TABLE "VOIP"."MONTHLY_BILLING_DETAILS" 
       (    "ID" NUMBER NOT NULL ENABLE, 
        "CDRRECORDTYPE" NUMBER, 
        "G_CALLMANAGERID" NUMBER, 
        "G_CALLID" NUMBER, 
        "O_LEGCALLIDENTIFIER" NUMBER, 
        "DATETIMEORIGINATION" NUMBER, 
        "O_NODEID" NUMBER, 
        "O_SPAN" NUMBER, 
        "O_IPADDR" NUMBER, 
        "CALLINGPARTYNUMBER" VARCHAR2(50 BYTE) NOT NULL ENABLE, 
        "CALLINGPARTY_USERID" VARCHAR2(128 BYTE), 
        "O_CAUSE_LOCATION" NUMBER, 
        "O_CAUSE_VALUE" NUMBER, 
        "O_PRECEDENCELEVEL" NUMBER, 
        "O_MEDIATRANSPORTADDR_IP" NUMBER, 
        "O_MEDIATRANSPORTADDR_PORT" NUMBER, 
        "O_MCAP_PAYLOADCAPABILITY" NUMBER, 
        "O_MCAP_MAXFRAMESPERPACKET" NUMBER, 
        "O_MCAP_G723BITRATE" NUMBER, 
        "O_VCAP_CODEC" NUMBER, 
        "O_VCAP_BANDWIDTH" NUMBER, 
        "O_VCAP_RESOLUTION" NUMBER, 
        "O_VIDEOTRANSPORTADDR_IP" NUMBER, 
        "O_VIDEOTRANSPORTADDR_PORT" NUMBER, 
        "O_RSVPAUDIOSTAT" VARCHAR2(64 BYTE), 
        "O_RSVPVIDEOSTAT" VARCHAR2(64 BYTE), 
        "DESTLEGIDENTIFIER" NUMBER, 
        "DESTNODEID" NUMBER, 
        "DESTSPAN" NUMBER, 
        "DESTIPADDR" NUMBER, 
        "ORIGINALCALLEDPARTYNUMBER" VARCHAR2(50 BYTE), 
        "FINALC_PARTYNUMBER" VARCHAR2(50 BYTE), 
        "FINALC_PARTY_USERID" VARCHAR2(128 BYTE), 
        "DESTCAUSE_LOCATION" NUMBER, 
        "DESTCAUSE_VALUE" NUMBER, 
        "DESTPRECEDENCELEVEL" NUMBER, 
        "DESTMEDIATRANSPORTADDR_IP" NUMBER, 
        "DESTMEDIATRANSPORTADDR_PORT" NUMBER, 
        "DESTMCAP_PAYLOADCAPABILITY" NUMBER, 
        "DESTMCAP_MAXFRAMESPERPACKET" NUMBER, 
        "DESTMCAP_G723BITRATE" NUMBER, 
        "DV_CAP_CODEC" NUMBER, 
        "DV_CAP_BANDWIDTH" NUMBER, 
        "DV_CAP_RESOLUTION" NUMBER, 
        "DV_TRANSPORTADDR_IP" NUMBER, 
        "DV_TRANSPORTADDR_PORT" NUMBER, 
        "DESTRSVPAUDIOSTAT" VARCHAR2(64 BYTE), 
        "DESTRSVPVIDEOSTAT" VARCHAR2(64 BYTE), 
        "DATETIMECONNECT" NUMBER, 
        "DATETIMEDISCONNECT" NUMBER, 
        "LASTREDIRECTDN" VARCHAR2(50 BYTE), 
        "PKID" VARCHAR2(4000 BYTE), 
        "O_INALCALLEDPARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "CALLINGPARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "FINALC_PARTYNUM_PARTITION" VARCHAR2(50 BYTE), 
        "LASTREDIRECTDNPARTITION" VARCHAR2(50 BYTE), 
        "DURATION" NUMBER, 
        "O_DEVICENAME" VARCHAR2(129 BYTE), 
        "DESTDEVICENAME" VARCHAR2(129 BYTE), 
        "O_CALLTERMINATION_BEHALF" NUMBER, 
        "DESTCALLTERMINATION_BEHALF" NUMBER, 
        "O_CALLEDPARTYREDIRECT_BEHALF" NUMBER, 
        "LASTREDIRECTREDIRECT_BEHALF" NUMBER, 
        "O_CALLEDPARTYREDIRECTREASON" NUMBER, 
        "LASTREDIRECTREDIRECTREASON" NUMBER, 
        "DESTCONVERSATIONID" NUMBER, 
        "G_CALLID_CLUSTERID" VARCHAR2(50 BYTE), 
        "JOIN_BEHALF" NUMBER, 
        "COMMENTS" VARCHAR2(2048 BYTE), 
        "AUTHCODEDESCRIPTION" VARCHAR2(50 BYTE), 
        "AUTHORIZATIONLEVEL" NUMBER, 
        "CLIENTMATTERCODE" VARCHAR2(32 BYTE), 
        "O_DTMFMETHOD" NUMBER, 
        "DESTDTMFMETHOD" NUMBER, 
        "CALLSECUREDSTATUS" NUMBER, 
        "O_CONVERSATIONID" NUMBER, 
        "O_MCAP_BANDWIDTH" NUMBER, 
        "DESTMCAP_BANDWIDTH" NUMBER, 
        "AUTHORIZATIONCODEVALUE" VARCHAR2(32 BYTE), 
        "OUTPULSEDCALLINGPARTYNUMBER" VARCHAR2(50 BYTE), 
        "OUTPULSEDCALLEDPARTYNUMBER" VARCHAR2(50 BYTE), 
        "O_IPV4V6ADDR" VARCHAR2(64 BYTE), 
        "DESTIPV4V6ADDR" VARCHAR2(64 BYTE), 
        "O_VCAP_CODEC_CHAN2" NUMBER, 
        "O_VCAP_BANDWIDTH_CHAN2" NUMBER, 
        "O_VCAP_RESOLUTION_CHAN2" NUMBER, 
        "O_V_TRANSPORTADDR_IP_CHAN2" NUMBER, 
        "O_V_TRANSPORTADDR_PORT_CHAN2" NUMBER, 
        "O_V_OCHANNEL_ROLE_CHAN2" NUMBER, 
        "DV_CAP_CODEC_CHAN2" NUMBER, 
        "DV_CAP_BANDWIDTH_CHAN2" NUMBER, 
        "DV_CAP_RESOLUTION_CHAN2" NUMBER, 
        "DV_TRANSPORTADDR_IP_CHAN2" NUMBER, 
        "DV_TRANSPORTADDR_PORT_CHAN2" NUMBER, 
        "DV_CHANNEL_ROLE_CHAN2" NUMBER, 
        "DATE_CREATED" DATE, 
        "DATETIME_CONNECT" DATE, 
        "DATETIME_DISCONNECT" DATE, 
        "USERID_EMAIL_ADDRESS" VARCHAR2(100 BYTE), 
        "FROM_FULL_TELEPHONE" VARCHAR2(20 BYTE), 
        "TO_FULL_TELEPHONE" VARCHAR2(20 BYTE), 
        "FROM_EXCHANGE" VARCHAR2(7 BYTE), 
        "TO_EXCHANGE" VARCHAR2(20 BYTE), 
        "FROM_CITY" VARCHAR2(200 BYTE), 
        "FROM_STATE" VARCHAR2(2 BYTE), 
        "TO_CITY" VARCHAR2(200 BYTE), 
        "TO_STATE" VARCHAR2(2 BYTE), 
        "CALL_TYPE" VARCHAR2(10 BYTE), 
         CONSTRAINT "MONTHLY_BILLING_PK" PRIMARY KEY ("ID")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA"  ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 75497472 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX1" ON "VOIP"."MONTHLY_BILLING_DETAILS" (TRUNC("DATETIME_CONNECT")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX10" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("CALL_TYPE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX2" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("FROM_EXCHANGE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX3" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("FROM_FULL_TELEPHONE", TRUNC("DATETIME_CONNECT")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX4" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT", NVL("FROM_FULL_TELEPHONE","CALLINGPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 5242880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX5" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT", NVL("TO_FULL_TELEPHONE","ORIGINALCALLEDPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 5242880 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX6" ON "VOIP"."MONTHLY_BILLING_DETAILS" (TO_CHAR("DATETIME_CONNECT",'fmMONTH YYYY')) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX7" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("TO_EXCHANGE") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX8" ON "VOIP"."MONTHLY_BILLING_DETAILS" (NVL("FROM_FULL_TELEPHONE","CALLINGPARTYNUMBER")) 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    
    
      CREATE INDEX "VOIP"."MONTHLY_BILL_INDEX9" ON "VOIP"."MONTHLY_BILLING_DETAILS" ("DATETIME_CONNECT") 
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
      STORAGE(INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "VOIPDATA" ;
    

    These are the functions to determine if a phone number is assigned to multiple staffs or departments:

    FUNCTION GET_EMPLOYEE_NAME (P_FROM_FULL_TELEPHONE IN VARCHAR2)
    RETURN VARCHAR2
    AS
      L_NAME EMPLOYEES.NAME%TYPE;
    BEGIN
      SELECT NAME
      INTO L_NAME
      FROM EMPLOYEES
      WHERE WORK_PHONE_1_FORMAT = P_FROM_FULL_TELEPHONE;
      
      RETURN L_NAME;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        L_NAME := 'Multiple Employees';
        RETURN L_NAME;
      WHEN NO_DATA_FOUND THEN
        L_NAME := 'No Employee Assigned';
        RETURN L_NAME;
      WHEN OTHERS THEN
        NULL;
    END;
    

    FUNCTION GET_DEPARTMENT_NAME (P_FROM_FULL_TELEPHONE IN VARCHAR2)
    RETURN VARCHAR2
    AS
      L_DEPT_DESCR EMPLOYEES.DEPT_DESCR%TYPE;
    BEGIN
      SELECT DEPT_DESCR
      INTO L_DEPT_DESCR
      FROM EMPLOYEES
      WHERE WORK_PHONE_1_FORMAT = P_FROM_FULL_TELEPHONE;
      
      RETURN L_DEPT_DESCR;
    EXCEPTION
      WHEN TOO_MANY_ROWS THEN
        L_DEPT_DESCR := 'Multiple Departments';
        RETURN L_DEPT_DESCR;
      WHEN NO_DATA_FOUND THEN
        L_DEPT_DESCR := 'No Department Assigned';
        RETURN L_DEPT_DESCR;
      WHEN OTHERS THEN
        NULL;
    END;
    

    This is the point of view that I'll use in the report:

    CREATE OR REPLACE FORCE VIEW "VOIP"."TOP_USERS_BY_CALLS_V" ("TOP_NO", "EMPLOYEE_NAME", "EMPLOYEE_DEPARTMENT", "PHONE_NUMBER", "QUANTITY_CALLS") AS 
      SELECT
      ROWNUM,
      VOIP_PKG.GET_EMPLOYEE_NAME(FROM_FULL_TELEPHONE),
      VOIP_PKG.GET_DEPARTMENT_NAME(FROM_FULL_TELEPHONE),
      FROM_FULL_TELEPHONE,
      QUANTITY_CALLS
    FROM (
    SELECT
      MBD.FROM_FULL_TELEPHONE,
      COUNT(1) QUANTITY_CALLS
    FROM
      MONTHLY_BILLING_DETAILS MBD
    WHERE
      MBD.FROM_FULL_TELEPHONE IS NOT NULL                                     AND
      MBD.FROM_FULL_TELEPHONE <> '000-000-0000'                               AND
      LENGTH(MBD.FROM_FULL_TELEPHONE) = 12                                    AND
      LENGTH(MBD.TO_FULL_TELEPHONE) = 12                                      AND
      SUBSTR(MBD.TO_FULL_TELEPHONE,1,3) NOT IN (SELECT AREA_CODE
                                                FROM NYNJ_METRO_AREA_CODES)   AND
      SUBSTR(MBD.TO_FULL_TELEPHONE,1,3) NOT IN ('800','822','833','844',
                                                '855','866','877','888')
    GROUP BY
      MBD.FROM_FULL_TELEPHONE
    ORDER BY
      QUANTITY_CALLS DESC
    )
    WHERE ROWNUM <= 100;
    

    Explain Plan output and Extended SQL Trace:


    SQL> 
    SQL> show parameter user_dump_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    user_dump_dest                       string      D:\ORACLEHOMES\ADMIN\RTS9\UDUM
                                                     P
    SQL> 
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.5
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    SQL> 
    SQL> show parameter db_file_multi
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count        integer     16
    SQL> 
    SQL> show parameter db_block_size
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_block_size                        integer     8192
    SQL> 
    SQL> show parameter cursor_sharing
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing                       string      EXACT
    SQL> 
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> 
    SQL> select
      2  sname
      3  , pname
      4  , pval1
      5  , pval2
      6  from
      7  sys.aux_stats$;
    
    SNAME                PNAME                     PVAL1 PVAL2
    -------------------- -------------------- ---------- --------------------
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          02-09-2009 15:46
    SYSSTATS_INFO        DSTOP                           02-09-2009 15:46
    SYSSTATS_INFO        FLAGS                         1
    SYSSTATS_MAIN        CPUSPEEDNW            1259.6206
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    
    13 rows selected.
    
    Elapsed: 00:00:00.03
    SQL> 
    SQL> explain plan for
      2  SELECT
      3    TOP_NO,
      4    EMPLOYEE_NAME,
      5    EMPLOYEE_DEPARTMENT,
      6    PHONE_NUMBER,
      7    QUANTITY_CALLS
      8  FROM
      9    TOP_USERS_BY_CALLS_V
     10  ORDER BY
     11    QUANTITY_CALLS DESC;
    
    Explained.
    
    Elapsed: 00:00:00.18
    SQL> 
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 826236322
    
    ----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   1 |  SORT ORDER BY                     |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |     1 |  4042 |  1312   (1)| 00:00:16 |
    |*  3 |    COUNT STOPKEY                   |                           |       |       |            |          |
    |   4 |     VIEW                           |                           |     1 |    25 |  1312   (1)| 00:00:16 |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |   6 |       HASH GROUP BY                |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |*  7 |        FILTER                      |                           |       |       |            |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |     1 |    26 |  1310   (1)| 00:00:16 |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |   934 |       |   449   (1)| 00:00:06 |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |     1 |     4 |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( NOT EXISTS (SELECT 0 FROM VOIP."NYNJ_METRO_AREA_CODES" "NYNJ_METRO_AREA_CODES" WHERE
                  LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3))))
       8 - filter(LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888')
       9 - filter(LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000'
                  AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL)
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    33 rows selected.
    
    Elapsed: 00:00:00.82
    SQL> 
    SQL> rollback;
    
    Rollback complete.
    
    Elapsed: 00:00:00.00
    SQL> 
    SQL> set autotrace traceonly arraysize 100
    SQL> 
    SQL> alter session set tracefile_identifier = 'mytrace1';
    
    Session altered.
    
    Elapsed: 00:00:00.01
    SQL> 
    SQL> alter session set events '10046 trace name context forever, level 8';
    
    Session altered.
    
    Elapsed: 00:00:00.15
    SQL> 
    SQL> SELECT
      2    TOP_NO,
      3    EMPLOYEE_NAME,
      4    EMPLOYEE_DEPARTMENT,
      5    PHONE_NUMBER,
      6    QUANTITY_CALLS
      7  FROM
      8    TOP_USERS_BY_CALLS_V
      9  ORDER BY
     10    QUANTITY_CALLS DESC;
    
    100 rows selected.
    
    Elapsed: 00:10:37.68
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 826236322
    
    ----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   1 |  SORT ORDER BY                     |                           |     1 |  4042 |  1313   (1)| 00:00:16 |
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |     1 |  4042 |  1312   (1)| 00:00:16 |
    |*  3 |    COUNT STOPKEY                   |                           |       |       |            |          |
    |   4 |     VIEW                           |                           |     1 |    25 |  1312   (1)| 00:00:16 |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |   6 |       HASH GROUP BY                |                           |     1 |    26 |  1312   (1)| 00:00:16 |
    |*  7 |        FILTER                      |                           |       |       |            |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |     1 |    26 |  1310   (1)| 00:00:16 |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |   934 |       |   449   (1)| 00:00:06 |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |     1 |     4 |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( NOT EXISTS (SELECT 0 FROM VOIP."NYNJ_METRO_AREA_CODES" "NYNJ_METRO_AREA_CODES" WHERE
                  LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3))))
       8 - filter(LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND
                  SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888')
       9 - filter(LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000'
                  AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL)
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    
    Statistics
    ----------------------------------------------------------
            365  recursive calls
              0  db block gets
         689543  consistent gets
         212906  physical reads
              0  redo size
           5984  bytes sent via SQL*Net to client
            400  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              2  sorts (memory)
              0  sorts (disk)
            100  rows processed
    
    SQL> 
    SQL> disconnect
    

    Part of the automatic trace output:

    SELECT
      TOP_NO,
      EMPLOYEE_NAME,
      EMPLOYEE_DEPARTMENT,
      PHONE_NUMBER,
      QUANTITY_CALLS
    FROM
      TOP_USERS_BY_CALLS_V
    ORDER BY
      QUANTITY_CALLS DESC
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.43          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2     24.70     635.81     212587     631823          0         100
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4     24.70     636.25     212587     631823          0         100
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 148  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
        100  SORT ORDER BY (cr=689531 pr=212900 pw=0 time=636823070 us)
        100   VIEW  TOP_USERS_BY_CALLS_V (cr=689531 pr=212900 pw=0 time=642681672 us)
        100    COUNT STOPKEY (cr=631823 pr=212587 pw=0 time=635667026 us)
        100     VIEW  (cr=631823 pr=212587 pw=0 time=635666810 us)
        100      SORT ORDER BY STOPKEY (cr=631823 pr=212587 pw=0 time=635666493 us)
       2512       HASH GROUP BY (cr=631823 pr=212587 pw=0 time=635666125 us)
      27112        FILTER  (cr=631823 pr=212587 pw=0 time=519230237 us)
     315563         TABLE ACCESS BY INDEX ROWID MONTHLY_BILLING_DETAILS (cr=381523 pr=212587 pw=0 time=580209555 us)
     394473          INDEX FULL SCAN MONTHLY_BILL_INDEX3 (cr=2679 pr=2679 pw=0 time=26793918 us)(object id 206675)
     226627         INDEX FULL SCAN NYNJ_METRO_AREA_CODES_UK1 (cr=250300 pr=0 pw=0 time=3575488 us)(object id 206605)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      db file sequential read                    212587        0.20        611.67
      SQL*Net message from client                     2        0.00          0.00
      SQL*Net more data to client                     2        0.00          0.00
    ********************************************************************************
    

    DBMS_XPLAN. Output DISPLAY_CURSOR:

    SQL> 
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  1ut636vt58jdw, child number 0
    -------------------------------------
    SELECT /*+ gather_plan_statistics */   TOP_NO,   EMPLOYEE_NAME,   EMPLOYEE_DEPARTMENT,   PHONE_NUMBER,   QUANTITY_CALLS FROM   TOP_USERS_BY_CALLS_V
    ORDER BY   QUANTITY_CALLS DESC
    
    Plan hash value: 826236322
    
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                          | Name                      | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                   |                           |      1 |        |    100 |00:09:56.06 |     689K|    210K|       |       |          |
    |   1 |  SORT ORDER BY                     |                           |      1 |      1 |    100 |00:09:56.06 |     689K|    210K| 13312 | 13312 |12288  (0)|
    |   2 |   VIEW                             | TOP_USERS_BY_CALLS_V      |      1 |      1 |    100 |00:10:04.98 |     689K|    210K|       |       |          |
    |*  3 |    COUNT STOPKEY                   |                           |      1 |        |    100 |00:09:54.89 |     631K|    210K|       |       |          |
    |   4 |     VIEW                           |                           |      1 |      1 |    100 |00:09:54.89 |     631K|    210K|       |       |          |
    |*  5 |      SORT ORDER BY STOPKEY         |                           |      1 |      1 |    100 |00:09:54.88 |     631K|    210K|  6144 |  6144 | 6144  (0)|
    |   6 |       HASH GROUP BY                |                           |      1 |      1 |   2512 |00:09:54.88 |     631K|    210K|   821K|   821K| 1153K (0)|
    |*  7 |        FILTER                      |                           |      1 |        |  27112 |00:08:58.57 |     631K|    210K|       |       |          |
    |*  8 |         TABLE ACCESS BY INDEX ROWID| MONTHLY_BILLING_DETAILS   |      1 |      1 |    315K|00:08:57.07 |     381K|    210K|       |       |          |
    |*  9 |          INDEX FULL SCAN           | MONTHLY_BILL_INDEX3       |      1 |    934 |    394K|00:00:23.02 |    2679 |   2679 |       |       |          |
    |* 10 |         INDEX FULL SCAN            | NYNJ_METRO_AREA_CODES_UK1 |    250K|      1 |    226K|00:00:03.47 |     250K|      0 |       |       |          |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(ROWNUM<=100)
       5 - filter(ROWNUM<=100)
       7 - filter( IS NULL)
       8 - filter((LENGTH("MBD"."TO_FULL_TELEPHONE")=12 AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'800' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'822'
                  AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'833' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'844' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'855'
                  AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'866' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'877' AND SUBSTR("MBD"."TO_FULL_TELEPHONE",1,3)<>'888'))
       9 - filter((LENGTH("MBD"."FROM_FULL_TELEPHONE")=12 AND "MBD"."FROM_FULL_TELEPHONE"<>'000-000-0000' AND "MBD"."FROM_FULL_TELEPHONE" IS NOT NULL))
      10 - filter(LNNVL("AREA_CODE"<>SUBSTR(:B1,1,3)))
    
    
    35 rows selected.
    
    Elapsed: 00:00:00.50
    SQL> 
    SQL> spool off
    
    

    Any help will be greatly appreciated. Please let me know if you need additional information.

    Thank you

    Erick

    ediazjorge wrote:

    Please let me know if you need additional information or do additional tests.

    Thanks again!

    Erick

    It's to you if you are satisfied or interested in improvements (if possible).

    If so the first thing I would like if you had your refreshed perspective as advised. According to expected area_code table cardinalities I doubt.

    So, if not cool off with dbms_stats.gather_table_stats on two tables, area_codes and MONTHLY_BILLING_DETAILS.

    Bottlenecks are now obviously the full table of MONTHLY_BILLING_DETAILS as well as the ANTI of LOOPS IMBRIQUEES scan.

    At the moment I don't think that an index of MONTHLY_BILLING_DETAILS will help a lot, because most of the lines will pass filter predicates, and because we need some columns in it, I have now I there will be gain a full index scan.

    I was surprissed that the optimizer pushes the substr <> predicates to both tables.

    So depending on your data, you might try

    1 make a factory of subquery select the two MONTHLY_BILLING_DETAILS columns that all directly apply predicates of membership and use it directly in the join instead of the table.

    or

    2. If all subtr to so are part of the table area_code choose in it using a subquery (or inline view) plant excluding these values.

    Both are attempts to get rid of the substr excluding as filters of join predicates.

    In fact, I was expecting a hash join anti as shown in the plan to explain instead of the nested loops anti, I expect to be more effective in this case.

    Perhaps with correct cardinalities the optimizier would understand himself.

    Just to test it, you can try the use_hash hint in the join:

    Select / * + USE_HASH (MBD, one) * /.

    ..

    OF MONTHLY_BILLING_DETAILS MBD,.

    NYNJ_METRO_AREA_CODES one

    (It's a good habit anyway usually use aliases and precede the names of columns. In the, it is easier to read queries are only trivial).

  • the SQL query result format

    Format the results of the SQL query, currently, show as below.

    Select license_type, correspondents of license_info where license_type in ('TEM', 'TDM') order by license_type;

    TDM 1445140800000000000
    TDM 1420952400000000000
    TDM 1444363200000000000
    TDM 1445054400000000000
    TDM 1428724800000000000
    TEM 1421125200000000000
    TEM 1423890000000000000
    TEM 1449637200000000000
    TEM 1444968000000000000
    TEM 1428724800000000000

    I need formatting like below

    Expected result:

    TDM 1445140800000000000 TEM 1421125200000000000
    TDM 1420952400000000000 TEM 1423890000000000000
    TDM 1444363200000000000 TEM 1449637200000000000
    TDM 1445054400000000000 TEM 1444968000000000000
    TDM 1428724800000000000 TEM 1428724800000000000

    I have sample data only, Blue said the change in your main table request

    Try:

    Select max (f1),

    Max (F2),

    Max (F3),

    Max (F4)

    de)

    Select decode (license_type, 'TDM' license_type) f1,

    Decode (license_type, 'TDM', expiration_date) f2,

    Decode (license_type, 'TEM' license_type) f3,

    Decode (license_type, 'TEM', expiration_date) f4,

    ROW_NUMBER() over (partition by order correspondents license_type) r

    Of

    )

    R group

    ----

    Ramin Hashimzade

  • The identical query, unusable performance in an environment - please help

    We strive to improve 10.2.0.4 to 11.2.0.2, but one of our considered requests is completely wrong (30 seconds in our current environment, 4000 in our upgraded environment).

    Note that the caveat is that it will be very difficult for me to edit the SQL code (his coming of another group of TI, as well as their position is that he should not have to be changed given the fact that it works so well in the current production environment).

    The query is exactly the same in both environments and transports the SQL_ID, but explain the plans are different.

    The environment in which the application works is version 10.2.0.4 and time the trace is 30,15 seconds, 841 rows returned.
    The new environment is 11.2.0.2, the elapsed time is 4035 seconds, 841 rows returned.

    The environments are comparable in terms of CPU/memory/IO (the two are written for on our NetApp NFS mounts)

    SGA_MAX/TARGET and PGA_AGGREGATE_TARGET are the same in both environments, as well as HASH_AREA_SIZE and SORT_AREA_SIZE.

    The table database is identical, and all of the indexes are the same in both environments. His stats were collected and this behavior has persisted through several reboots of the databases.

    I ran traces on statements in both environments and the performance difference seems to be due to direct path read/write temp:

    The SQL
    SELECT DISTINCT
             a.emplid,
             a.name,
             rds.sa_get_stdnt_email_fn (a.emplid),
             a.req_term,
             a.req_term_ldesc,
             CASE
                WHEN (a.req_acad_plan = 'PKINXXXBBS' AND a.cum_gpa >= d.gpa)
                THEN
                   NVL (c.num_met, 0) + 1
                WHEN (b.gpa >= d.gpa AND a.req_acad_plan <> 'PKINXXXBBS')
                THEN
                   NVL (c.num_met, 0) + 1
                ELSE
                   NVL (c.num_met, 0)
             END
                AS "Requirement Status",
             a.cum_total_passed AS "Cumulative Units",
             a.admit_term,
             a.admit_term_ldesc,
             a.acad_plan,
             a.acad_plan_ldesc,
             a.academic_level,
             a.academic_level_ldesc,
             TO_CHAR (a.rpt_date, 'MM/DD/YYYY') AS rpt_date,
             TO_CHAR (NVL (b.gpa, 0), '0.000') AS gpa,
             TO_CHAR (NVL (a.cum_gpa, 0), '0.000') AS cum_gpa
        FROM sa.rec_sm_stdnt_deg_completion a,
             (  SELECT DISTINCT
                       CASE
                          WHEN SUM (b_sub.units_earned) = 0 THEN 0
                          ELSE SUM (b_sub.grade_points) / SUM (b_sub.units_earned)
                       END
                          AS gpa,
                       b_sub.emplid,
                       b_sub.acad_career,
                       b_sub.acad_plan,
                       b_sub.req_acad_plan,
                       b_sub.req_term,
                       b_sub.academic_level,
                       b_sub.rqrmnt_group
                  FROM sa.rec_sm_stdnt_deg_completion b_sub,
                       hrsa_extr.ps_rq_grp_tbl g3,
                       hrsa_extr.ps_rq_main_tbl m3
                 WHERE     b_sub.req_acad_plan IS NOT NULL
                       AND b_sub.acad_career = 'UGRD'
                       AND b_sub.acad_prog = 'UBACH'
                       AND b_sub.acad_plan = b_sub.req_acad_plan
                       AND b_sub.grade <> 'IP'
                       AND b_sub.impact_flag = 'Y'
                       AND g3.effdt =
                              (SELECT MAX (g3_ed.effdt)
                                 FROM hrsa_extr.ps_rq_grp_tbl g3_ed
                                WHERE     g3_ed.rqrmnt_group = g3.rqrmnt_group
                                      AND g3_ed.effdt <= b_sub.req_term_begin_date)
                       AND g3.rqrmnt_group = b_sub.rqrmnt_group
                       AND m3.effdt =
                              (SELECT MAX (m3_ed.effdt)
                                 FROM hrsa_extr.ps_rq_main_tbl m3_ed
                                WHERE     m3_ed.requirement = m3.requirement
                                      AND m3_ed.effdt <= b_sub.req_term_begin_date)
                       AND m3.requirement = b_sub.requirement
              GROUP BY b_sub.emplid,
                       b_sub.acad_career,
                       b_sub.acad_plan,
                       b_sub.req_acad_plan,
                       b_sub.req_term,
                       b_sub.academic_level,
                       b_sub.rqrmnt_group) b,
             (  SELECT c_sub.emplid,
                       c_sub.acad_career,
                       c_sub.acad_plan,
                       c_sub.req_acad_plan,
                       c_sub.req_term,
                       c_sub.academic_level,
                       c_sub.rqrmnt_group,
                       COUNT (*) AS num_met
                  FROM sa.rec_sm_stdnt_deg_completion c_sub,
                       hrsa_extr.ps_rq_grp_tbl g2,
                       hrsa_extr.ps_rq_main_tbl m2
                 WHERE     c_sub.rqrmnt_line_status = 'COMP'
                       AND c_sub.grade <> 'IP'
                       AND c_sub.impact_flag = 'Y'
                       AND c_sub.acad_career = 'UGRD'
                       AND c_sub.acad_prog = 'UBACH'
                       AND c_sub.acad_plan = c_sub.req_acad_plan
                       AND g2.effdt =
                              (SELECT MAX (g2_ed.effdt)
                                 FROM hrsa_extr.ps_rq_grp_tbl g2_ed
                                WHERE     g2_ed.rqrmnt_group = g2.rqrmnt_group
                                      AND g2_ed.effdt <= c_sub.req_term_begin_date)
                       AND g2.rqrmnt_group = c_sub.rqrmnt_group
                       AND m2.effdt =
                              (SELECT MAX (m2_ed.effdt)
                                 FROM hrsa_extr.ps_rq_main_tbl m2_ed
                                WHERE     m2_ed.requirement = m2.requirement
                                      AND m2_ed.effdt <= c_sub.req_term_begin_date)
                       AND m2.requirement = c_sub.requirement
              GROUP BY c_sub.emplid,
                       c_sub.acad_career,
                       c_sub.acad_plan,
                       c_sub.req_acad_plan,
                       c_sub.req_term,
                       c_sub.academic_level,
                       c_sub.rqrmnt_group) c,
             hrsa_extr.ps_smo_rdr_imp_pln d,
             hrsa_extr.ps_rq_grp_tbl g,
             hrsa_extr.ps_rq_main_tbl m
       WHERE     a.acad_career = 'UGRD'
             AND a.acad_prog = 'UBACH'
             AND a.req_acad_plan IN (N'NUPPXXXBBS', N'NURPBASBBS', N'NURPXXXBBS')
             AND a.academic_level IN (N'10', N'20', N'30', N'40', N'50', N'GR')
             AND a.acad_plan = a.req_acad_plan
             AND a.impact_flag = 'Y'
             AND g.effdt =
                    (SELECT MAX (g_ed.effdt)
                       FROM hrsa_extr.ps_rq_grp_tbl g_ed
                      WHERE     g_ed.rqrmnt_group = g.rqrmnt_group
                            AND g_ed.effdt <= a.req_term_begin_date)
             AND g.rqrmnt_group = a.rqrmnt_group
             AND m.effdt =
                    (SELECT MAX (m_ed.effdt)
                       FROM hrsa_extr.ps_rq_main_tbl m_ed
                      WHERE     m_ed.requirement = m.requirement
                            AND m_ed.effdt <= a.req_term_begin_date)
             AND m.requirement = a.requirement
             AND a.emplid = b.emplid(+)
             AND a.acad_career = b.acad_career(+)
             AND a.acad_plan = b.acad_plan(+)
             AND a.req_acad_plan = b.req_acad_plan(+)
             AND a.academic_level = b.academic_level(+)
             AND a.req_term = b.req_term(+)
             AND a.rqrmnt_group = b.rqrmnt_group(+)
             AND a.emplid = c.emplid(+)
             AND a.acad_career = c.acad_career(+)
             AND a.acad_plan = c.acad_plan(+)
             AND a.req_acad_plan = c.req_acad_plan(+)
             AND a.academic_level = c.academic_level(+)
             AND a.req_term = c.req_term(+)
             AND a.rqrmnt_group = c.rqrmnt_group(+)
             AND d.acad_plan = a.req_acad_plan
    ORDER BY 6 DESC, 2 ASC;
    New environment (11.2.0.2), takes 4000 seconds according to tkprof

    Explain plan
    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 4117596694
    
    -------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                 | Name                        | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                          |                             |     1 |   314 | 15231   (1)| 00:03:03 |
    |   1 |  SORT UNIQUE                              |                             |     1 |   314 | 15230   (1)| 00:03:03 |
    |   2 |   NESTED LOOPS OUTER                      |                             |     1 |   314 | 15227   (1)| 00:03:03 |
    |   3 |    NESTED LOOPS OUTER                     |                             |     1 |   285 | 15216   (1)| 00:03:03 |
    |   4 |     NESTED LOOPS                          |                             |     1 |   256 | 15205   (1)| 00:03:03 |
    |   5 |      NESTED LOOPS                         |                             |     1 |   241 | 15204   (1)| 00:03:03 |
    |   6 |       NESTED LOOPS                        |                             |     1 |   223 | 15203   (1)| 00:03:03 |
    |   7 |        NESTED LOOPS                       |                             |    17 |   731 | 15186   (1)| 00:03:03 |
    |   8 |         VIEW                              | VW_SQ_3                     |   998 | 27944 | 15186   (1)| 00:03:03 |
    |   9 |          HASH GROUP BY                    |                             |   998 | 62874 | 15186   (1)| 00:03:03 |
    |  10 |           MERGE JOIN                      |                             | 29060 |  1787K| 15184   (1)| 00:03:03 |
    |  11 |            SORT JOIN                      |                             |    26 |  1248 | 15180   (1)| 00:03:03 |
    |  12 |             TABLE ACCESS BY INDEX ROWID   | REC_SM_STDNT_DEG_COMPLETION |    26 |  1248 | 15179   (1)| 00:03:03 |
    |* 13 |              INDEX SKIP SCAN              | REC0SM_STDNT_DEG_IDX        |    26 |       | 15168   (1)| 00:03:03 |
    |* 14 |            SORT JOIN                      |                             |  1217 | 18255 |     4  (25)| 00:00:01 |
    |  15 |             INDEX FAST FULL SCAN          | PS3RQ_GRP_TBL               |  1217 | 18255 |     3   (0)| 00:00:01 |
    |* 16 |         INDEX UNIQUE SCAN                 | PS_RQ_GRP_TBL               |     1 |    15 |     0   (0)| 00:00:01 |
    |* 17 |        TABLE ACCESS BY USER ROWID         | REC_SM_STDNT_DEG_COMPLETION |     1 |   180 |     1   (0)| 00:00:01 |
    |* 18 |       INDEX RANGE SCAN                    | PS_RQ_MAIN_TBL              |     1 |    18 |     1   (0)| 00:00:01 |
    |  19 |        SORT AGGREGATE                     |                             |     1 |    18 |            |          |
    |  20 |         FIRST ROW                         |                             |     1 |    18 |     2   (0)| 00:00:01 |
    |* 21 |          INDEX RANGE SCAN (MIN/MAX)       | PS_RQ_MAIN_TBL              |     1 |    18 |     2   (0)| 00:00:01 |
    |* 22 |      INDEX FULL SCAN                      | PS0SMO_RDR_IMP_PLN          |     1 |    15 |     1   (0)| 00:00:01 |
    |* 23 |     VIEW PUSHED PREDICATE                 |                             |     1 |    29 |    11  (19)| 00:00:01 |
    |  24 |      SORT GROUP BY                        |                             |     1 |    52 |    11  (19)| 00:00:01 |
    |  25 |       VIEW                                | VM_NWVW_5                   |     1 |    52 |    10  (10)| 00:00:01 |
    |* 26 |        FILTER                             |                             |       |       |            |          |
    |  27 |         SORT GROUP BY                     |                             |     1 |   165 |    10  (10)| 00:00:01 |
    |* 28 |          FILTER                           |                             |       |       |            |          |
    |  29 |           NESTED LOOPS                    |                             |     1 |   165 |     7   (0)| 00:00:01 |
    |  30 |            NESTED LOOPS                   |                             |     1 |   147 |     6   (0)| 00:00:01 |
    |  31 |             NESTED LOOPS                  |                             |     1 |   117 |     5   (0)| 00:00:01 |
    |* 32 |              TABLE ACCESS BY INDEX ROWID  | REC_SM_STDNT_DEG_COMPLETION |     1 |    90 |     4   (0)| 00:00:01 |
    |* 33 |               INDEX RANGE SCAN            | REC1SM_STDNT_DEG_IDX        |     1 |       |     3   (0)| 00:00:01 |
    |* 34 |              INDEX RANGE SCAN             | PS_RQ_GRP_TBL               |     1 |    27 |     1   (0)| 00:00:01 |
    |  35 |               SORT AGGREGATE              |                             |     1 |    15 |            |          |
    |  36 |                FIRST ROW                  |                             |     1 |    15 |     2   (0)| 00:00:01 |
    |* 37 |                 INDEX RANGE SCAN (MIN/MAX)| PS_RQ_GRP_TBL               |     1 |    15 |     2   (0)| 00:00:01 |
    |* 38 |             INDEX RANGE SCAN              | PS_RQ_MAIN_TBL              |     1 |    30 |     1   (0)| 00:00:01 |
    |* 39 |            INDEX RANGE SCAN               | PS_RQ_MAIN_TBL              |     1 |    18 |     1   (0)| 00:00:01 |
    |* 40 |    VIEW PUSHED PREDICATE                  |                             |     1 |    29 |    11  (19)| 00:00:01 |
    |  41 |     SORT GROUP BY                         |                             |     1 |    32 |    11  (19)| 00:00:01 |
    |  42 |      VIEW                                 | VM_NWVW_4                   |     1 |    32 |    10  (10)| 00:00:01 |
    |* 43 |       FILTER                              |                             |       |       |            |          |
    |  44 |        SORT GROUP BY                      |                             |     1 |   166 |    10  (10)| 00:00:01 |
    |* 45 |         FILTER                            |                             |       |       |            |          |
    |* 46 |          FILTER                           |                             |       |       |            |          |
    |  47 |           NESTED LOOPS                    |                             |     1 |   166 |     7   (0)| 00:00:01 |
    |  48 |            NESTED LOOPS                   |                             |     1 |   148 |     6   (0)| 00:00:01 |
    |  49 |             NESTED LOOPS                  |                             |     1 |   118 |     5   (0)| 00:00:01 |
    |* 50 |              INDEX RANGE SCAN             | PS_RQ_GRP_TBL               |     1 |    27 |     2   (0)| 00:00:01 |
    |* 51 |              TABLE ACCESS BY INDEX ROWID  | REC_SM_STDNT_DEG_COMPLETION |     1 |    91 |     3   (0)| 00:00:01 |
    |* 52 |               INDEX RANGE SCAN            | REC1SM_STDNT_DEG_IDX        |     1 |       |     2   (0)| 00:00:01 |
    |* 53 |             INDEX RANGE SCAN              | PS_RQ_MAIN_TBL              |     1 |    30 |     1   (0)| 00:00:01 |
    |* 54 |            INDEX RANGE SCAN               | PS_RQ_MAIN_TBL              |     1 |    18 |     1   (0)| 00:00:01 |
    |  55 |          SORT AGGREGATE                   |                             |     1 |    15 |            |          |
    |  56 |           FIRST ROW                       |                             |     1 |    15 |     2   (0)| 00:00:01 |
    |* 57 |            INDEX RANGE SCAN (MIN/MAX)     | PS_RQ_GRP_TBL               |     1 |    15 |     2   (0)| 00:00:01 |
    -------------------------------------------------------------------------------------------------------------------------
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      6.59       6.66          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2   1521.36    4028.91    2256624  240053408          0         841
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4   1527.95    4035.57    2256624  240053408          0         841
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      Disk file operations I/O                        3        0.07          0.11
      db file sequential read                     10829        0.12         16.62
      direct path write temp                      72445        0.30        293.71
      direct path read temp                       72445        0.58       2234.14
      asynch descriptor resize                       22        0.00          0.00
      SQL*Net more data to client                     9        0.00          0.00
      SQL*Net message from client                     2        0.84          1.25
    ********************************************************************************
    The current production (10.2.0.4), takes 30 seconds
    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 2178773127
    
    ------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                | Name                        | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                         |                             |     1 |   331 | 89446   (2)| 00:17:54 |
    |   1 |  SORT UNIQUE                             |                             |     1 |   331 | 89445   (2)| 00:17:54 |
    |   2 |   NESTED LOOPS                           |                             |     1 |   331 | 89440   (2)| 00:17:54 |
    |   3 |    NESTED LOOPS                          |                             |     1 |   316 | 89439   (2)| 00:17:54 |
    |*  4 |     HASH JOIN OUTER                      |                             |     1 |   298 | 89438   (2)| 00:17:54 |
    |*  5 |      HASH JOIN OUTER                     |                             |     1 |   240 | 59625   (2)| 00:11:56 |
    |   6 |       NESTED LOOPS                       |                             |     1 |   182 | 29815   (2)| 00:05:58 |
    |*  7 |        TABLE ACCESS FULL                 | REC_SM_STDNT_DEG_COMPLETION |     1 |   167 | 29814   (2)| 00:05:58 |
    |*  8 |        INDEX FULL SCAN                   | PS0SMO_RDR_IMP_PLN          |     1 |    15 |     1   (0)| 00:00:01 |
    |   9 |       VIEW                               |                             |     1 |    58 | 29809   (2)| 00:05:58 |
    |  10 |        HASH GROUP BY                     |                             |     1 |    71 | 29809   (2)| 00:05:58 |
    |  11 |         VIEW                             |                             |     1 |    71 | 29809   (2)| 00:05:58 |
    |* 12 |          FILTER                          |                             |       |       |            |          |
    |  13 |           HASH GROUP BY                  |                             |     1 |   198 | 29809   (2)| 00:05:58 |
    |  14 |            NESTED LOOPS                  |                             |     1 |   198 | 29806   (2)| 00:05:58 |
    |* 15 |             HASH JOIN                    |                             |     1 |   171 | 29805   (2)| 00:05:58 |
    |* 16 |              HASH JOIN                   |                             |     4 |   572 | 29802   (2)| 00:05:58 |
    |* 17 |               TABLE ACCESS FULL          | REC_SM_STDNT_DEG_COMPLETION |     4 |   452 | 29798   (2)| 00:05:58 |
    |  18 |               INDEX FAST FULL SCAN       | PS2RQ_MAIN_TBL              |  1035 | 31050 |     3   (0)| 00:00:01 |
    |  19 |              INDEX FAST FULL SCAN        | PS2RQ_MAIN_TBL              |  1035 | 28980 |     3   (0)| 00:00:01 |
    |* 20 |             INDEX RANGE SCAN             | PS_RQ_GRP_TBL               |     1 |    27 |     1   (0)| 00:00:01 |
    |  21 |              SORT AGGREGATE              |                             |     1 |    15 |            |          |
    |  22 |               FIRST ROW                  |                             |     1 |    15 |     2   (0)| 00:00:01 |
    |* 23 |                INDEX RANGE SCAN (MIN/MAX)| PS_RQ_GRP_TBL               |     1 |    15 |     2   (0)| 00:00:01 |
    |  24 |      VIEW                                |                             |     1 |    58 | 29813   (2)| 00:05:58 |
    |  25 |       HASH GROUP BY                      |                             |     1 |    45 | 29813   (2)| 00:05:58 |
    |  26 |        VIEW                              |                             |     1 |    45 | 29813   (2)| 00:05:58 |
    |* 27 |         FILTER                           |                             |       |       |            |          |
    |  28 |          HASH GROUP BY                   |                             |     1 |   199 | 29813   (2)| 00:05:58 |
    |  29 |           NESTED LOOPS                   |                             |     1 |   199 | 29810   (2)| 00:05:58 |
    |* 30 |            HASH JOIN                     |                             |     1 |   172 | 29809   (2)| 00:05:58 |
    |* 31 |             HASH JOIN                    |                             |     8 |  1152 | 29805   (2)| 00:05:58 |
    |* 32 |              TABLE ACCESS FULL           | REC_SM_STDNT_DEG_COMPLETION |     7 |   798 | 29802   (2)| 00:05:58 |
    |  33 |              INDEX FAST FULL SCAN        | PS2RQ_MAIN_TBL              |  1035 | 31050 |     3   (0)| 00:00:01 |
    |  34 |             INDEX FAST FULL SCAN         | PS2RQ_MAIN_TBL              |  1035 | 28980 |     3   (0)| 00:00:01 |
    |* 35 |            INDEX RANGE SCAN              | PS_RQ_GRP_TBL               |     1 |    27 |     1   (0)| 00:00:01 |
    |  36 |             SORT AGGREGATE               |                             |     1 |    15 |            |          |
    |  37 |              FIRST ROW                   |                             |     1 |    15 |     2   (0)| 00:00:01 |
    |* 38 |               INDEX RANGE SCAN (MIN/MAX) | PS_RQ_GRP_TBL               |     1 |    15 |     2   (0)| 00:00:01 |
    |* 39 |     INDEX RANGE SCAN                     | PS_RQ_MAIN_TBL              |     1 |    18 |     1   (0)| 00:00:01 |
    |  40 |      SORT AGGREGATE                      |                             |     1 |    18 |            |          |
    |  41 |       FIRST ROW                          |                             |     1 |    18 |     2   (0)| 00:00:01 |
    |* 42 |        INDEX RANGE SCAN (MIN/MAX)        | PS_RQ_MAIN_TBL              |     1 |    18 |     2   (0)| 00:00:01 |
    |* 43 |    INDEX RANGE SCAN                      | PS_RQ_GRP_TBL               |     1 |    15 |     1   (0)| 00:00:01 |
    |  44 |     SORT AGGREGATE                       |                             |     1 |    15 |            |          |
    |  45 |      FIRST ROW                           |                             |     1 |    15 |     2   (0)| 00:00:01 |
    |* 46 |       INDEX RANGE SCAN (MIN/MAX)         | PS_RQ_GRP_TBL               |     1 |    15 |     2   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------------------------------------------
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      1.49       1.51          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2     18.25      28.63     463672     932215          0         836
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4     19.75      30.15     463672     932215          0         836
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      db file scattered read                      14262        0.31         13.13
      latch: shared pool                              1        0.01          0.01
      db file sequential read                         7        0.00          0.00
      direct path write temp                        493        0.00          0.00
      direct path read temp                         493        0.00          0.00
      SQL*Net more data to client                    40        0.00          0.00
      SQL*Net message from client                     2        0.83          1.23
    ********************************************************************************
    Published by: ngilbert on June 26, 2012 16:40

    Published by: ngilbert on June 26, 2012 16:41

    Hello

    as is almost always the case, your bad plan is the result of messed up the cardinality estimates. The biggest problem seems to be the cardinality in steps 12 and 13 of the bad plan:

    |  12 |             TABLE ACCESS BY INDEX ROWID   | REC_SM_STDNT_DEG_COMPLETION |    26 |  1248 | 15179   (1)| 00:03:03 |
    |* 13 |              INDEX SKIP SCAN              | REC0SM_STDNT_DEG_IDX        |    26 |       | 15168   (1)| 00:03:03 |
    

    that is the estimated cardinality is 26. But if we look at the map, we see that the actual number of lines is 4 orders of magnitude (!) higher than that. So of course this goes wrong from there: the optimizer uses weird join methods, wrong join order etc.

    And if we look at the predicate:

    13 - access("A"."ACAD_CAREER"='UGRD' AND "A"."ACAD_PROG"='UBACH' AND "A"."IMPACT_FLAG"='Y')
           filter("A"."ACAD_PLAN"="A"."REQ_ACAD_PLAN" AND "A"."ACAD_PROG"='UBACH' AND "A"."IMPACT_FLAG"='Y' AND
                  "A"."ACAD_CAREER"='UGRD')
    

    We can assume that the problem is related to the related predicates: you select lines of tables with 4 equality predicates, but 260 k lines survive this filtering. The optimizer thinks that it is closer to 26, not 260 k, but it's probably because the predicates are not really independent.

    There is another thing that seems suspicious: filter predicate is redundant with the predicates of access. There is another discussion on OTN not so long ago, and it turned out to be a symptom of a bug (which makes it even more suspect, is that it was also a SKIP SCAN). See:

    Re: CBO does not consider cheaper NL-Plan without guidance

    Hope that was helpful.

    Best regards
    Nikolai

  • Query in Oracle 10 fast but slow in Oracle 11

    Hi all

    We have a query that runs smoothly in Oracle 10 g. It takes less then a second. We installed a second server and import/export to create the same 11g database. On this 11g database query takes a long time (like 8 seconds or more).

    Here are the details. Maybe someone can tell us the reason why this happens.

    We are talking about this statement:
    Select nvl(sum(BM_OPENST_D - BM_OPENST_CR),0) 
    from bh.bh123gh
    where 
    F123_AR_NR>='4400000000' and
    F123_AR_NR<='4404000000' and
    F123_KL_LEV_AR_NR='0631001000' and
    SRT_REK=2 and
    F123_BKJR>=0000 and
    F123_BKJR<=2011 and
    F123_FIRMA=2;
    Version of database is 11.2.0.1.0
    SQL> 
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_capture_sql_plan_baselines boolean     FALSE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      11.2.0.1
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    optimizer_use_invisible_indexes      boolean     FALSE
    optimizer_use_pending_statistics     boolean     FALSE
    optimizer_use_sql_plan_baselines     boolean     TRUE
    SQL> 
    SQL> show parameter db_file_multi
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count        integer     6
    SQL> 
    SQL> show parameter db_block_size
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_block_size                        integer     8192
    SQL> 
    SQL> show parameter cursor_sharing
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing                       string      EXACT
    SQL> 
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> 
    SQL> select         sname
      2              , pname
      3              , pval1
      4              , pval2
      5  from
      6              sys.aux_stats$;
    
    SNAME                PNAME                     PVAL1 PVAL2
    -------------------- -------------------- ---------- --------------------
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          03-30-2010 11:05
    SYSSTATS_INFO        DSTOP                           03-30-2010 11:05
    SYSSTATS_INFO        FLAGS                         1
    SYSSTATS_MAIN        CPUSPEEDNW           1183.90219
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    
    13 rows selected.
    
    Elapsed: 00:00:00.03
    SQL> 
    SQL> explain plan for
      2  Select nvl(sum(BM_OPENST_DEB - BM_OPENST_CR),0)
      3  from bh.bh123gh
      4  where
      5  F123_AR_NR>='4400000000' and
      6  F123_AR_NR<='4404000000' and
      7  F123_KL_LEV_AR_NR='0631001000' and
      8  SRT_REK=2 and
      9  F123_BKJR>=0000 and
     10  F123_BKJR<=2011 and
     11  F123_FIRMA=2;
    
    Explained.
    
    Elapsed: 00:00:00.10
    SQL> 
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 3488495774
    
    -------------------------------------------------------------------------------------------------
    | Id  | Operation                    | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |                  |     1 |    38 |  1792   (1)| 00:00:22 |
    |   1 |  SORT AGGREGATE              |                  |     1 |    38 |            |          |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| BH123GH          |  5059 |   187K|  1792   (1)| 00:00:22 |
    |*  3 |    INDEX RANGE SCAN          | I_BH123GH_ISABEL |  5059 |       |   145   (0)| 00:00:02 |
    -------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter("F123_BKJR">=0000 AND "F123_BKJR"<=2011)
       3 - access("F123_FIRMA"=2 AND "SRT_REK"=2 AND "F123_KL_LEV_AR_NR"='0631001000'
                  AND "F123_AR_NR">='4400000000' AND "F123_AR_NR"<='4404000000')
           filter("F123_AR_NR"<='4404000000' AND "F123_AR_NR">='4400000000')
    
    18 rows selected.
    
    Elapsed: 00:00:00.20
    SQL> 
    SQL> rollback;
    
    Rollback complete.
    
    Elapsed: 00:00:00.01
    SQL> 
    SQL> rem Set the ARRAYSIZE according to your application
    SQL> set autotrace traceonly arraysize 100
    SQL> 
    SQL> alter session set tracefile_identifier = 'mytrace1';
    
    Session altered.
    
    Elapsed: 00:00:00.01
    SQL> 
    SQL> rem if you're using bind variables
    SQL> rem define them here
    SQL> 
    SQL> rem variable b_var1 number
    SQL> rem variable b_var2 varchar2(20)
    SQL> 
    SQL> rem and initialize them
    SQL> 
    SQL> rem exec :b_var1 := 1
    SQL> rem exec :b_var2 := 'DIAG'
    SQL> 
    SQL> alter session set events '10046 trace name context forever, level 8';
    
    Session altered.
    
    Elapsed: 00:00:00.03
    SQL> 
    SQL> -- put your statement here
    SQL> Select nvl(sum(BM_OPENST_D - BM_OPENST_CR),0)
      2  from bh.bh123gh
      3  where
      4  F123_AR_NR>='4400000000' and
      5  F123_AR_NR<='4404000000' and
      6  F123_KL_LEV_AR_NR='0631001000' and
      7  SRT_REK=2 and
      8  F123_BKJR>=0000 and
      9  F123_BKJR<=2011 and
     10  F123_FIRMA=2;
    
    Elapsed: 00:00:09.92
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3488495774
    
    -------------------------------------------------------------------------------------------------
    | Id  | Operation                    | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |                  |     1 |    38 |  1792   (1)| 00:00:22 |
    |   1 |  SORT AGGREGATE              |                  |     1 |    38 |            |          |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| BH123GH          |  5059 |   187K|  1792   (1)| 00:00:22 |
    |*  3 |    INDEX RANGE SCAN          | I_BH123GH_ISABEL |  5059 |       |   145   (0)| 00:00:02 |
    -------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter("F123_BKJR">=0000 AND "F123_BKJR"<=2011)
       3 - access("F123_FIRMA"=2 AND "SRT_REK"=2 AND "F123_KL_LEV_AR_NR"='0631001000'
                  AND "F123_AR_NR">='4400000000' AND "F123_AR_NR"<='4404000000')
           filter("F123_AR_NR"<='4404000000' AND "F123_AR_NR">='4400000000')
    
    
    Statistics
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
          11104  consistent gets
           9434  physical reads
              0  redo size
            574  bytes sent via SQL*Net to client
            519  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    
    SQL> 
    SQL> disconnect
    Disconnected from Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    SQL> 
    SQL> spool off
    The trace output:
    TKPROF: Release 11.2.0.1.0 - Development on Tue Nov 22 13:58:33 2011
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Trace file: C:\Oracle\diag\rdbms\oravopak\oravopak\trace\oravopak_ora_7352_mytrace1.trc
    Sort options: default
    
    ********************************************************************************
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing 
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    ********************************************************************************
    
    Select nvl(sum(BM_OPENST_D - BM_OPENST_CR),0)
    from bh.bh123gh
    where
    F123_AR_NR>='4400000000' and
    F123_AR_NR<='4404000000' and
    F123_KL_LEV_AR_NR='0631001000' and
    SRT_REK=2 and
    F123_BKJR>=0000 and
    F123_BKJR<=2011 and
    F123_FIRMA=2
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.03       9.86       9434      11104          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4      0.04       9.87       9434      11104          0           1
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: SYS
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          1  SORT AGGREGATE (cr=11104 pr=9434 pw=0 time=0 us)
      67250   TABLE ACCESS BY INDEX ROWID BH123GH (cr=11104 pr=9434 pw=0 time=10500177 us cost=1792 size=192242 card=5059)
      67250    INDEX RANGE SCAN I_BH123GH_ISABEL (cr=526 pr=550 pw=0 time=44363 us cost=145 size=0 card=5059)(object id 75061)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      Disk file operations I/O                        1        0.00          0.00
      db file sequential read                      8893        0.10          9.26
      db file scattered read                          7        0.01          0.05
      db file parallel read                           1        0.02          0.02
      SQL*Net message from client                     2        0.00          0.00
    ********************************************************************************
    DBMS_XPLAN. Output DISPLAY_CURSOR:
    SQL> 
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  g6pkv639sdfgw, child number 0
    -------------------------------------
    Select /*+ gather_plan_statistics */ nvl(sum(BM_OPENST_DEB -
    BM_OPENST_CR),0) from bh.bh123gh where F123_AR_NR>='4400000000'
    and F123_AR_NR<='4404000000' and F123_KL_LEV_AR_NR='0631001000' and
    SRT_REK=2 and F123_BKJR>=0000 and F123_BKJR<=2011 and
    F123_FIRMA=2
    
    Plan hash value: 3488495774
    
    --------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                    | Name             | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
    --------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |                  |      1 |        |      1 |00:00:08.07 |   11104 |  13531 |
    |   1 |  SORT AGGREGATE              |                  |      1 |      1 |      1 |00:00:08.07 |   11104 |  13531 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| BH123GH          |      1 |   5059 |  67250 |00:00:10.90 |   11104 |  13531 |
    |*  3 |    INDEX RANGE SCAN          | I_BH123GH_ISABEL |      1 |   5059 |  67250 |00:00:00.05 |     526 |    550 |
    --------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter(("F123_BKJR">=0 AND "F123_BKJR"<=2011))
       3 - access("F123_FIRMA"=2 AND "SRT_REK"=2 AND "F123_KL_LEV_AR_NR"='0631001000' AND
                  "F123_AR_NR">='4400000000' AND "F123_AR_NR"<='4404000000')
           filter(("F123_AR_NR"<='4404000000' AND "F123_AR_NR">='4400000000'))
    
    
    27 rows selected.
    
    Elapsed: 00:00:01.15
    SQL> 
    SQL> spool off

    Addition to other boards who has been submitted, a few more suggestions:
    * It seems that your DB_FILE_MULTIBLOCK_READ_COUNT parameter has been manually set to a value of 6 (or you have the SESSIONS parameter set to a high value with a small CMS). As a general rule, this should only be set under Oracle database 10.2 and higher. See:
    http://jonathanlewis.WordPress.com/2007/05/20/system-stats-strategy/

    * You have statistics of the noworkload system - it will not necessarily change things for the better for this SQL query special, but you might consider to collect statistics of the workload when the system is covered by a typical to high load. See:
    http://hoopercharles.WordPress.com/2011/05/04/how-to-collect-statistics/

    * As Toon mentioned, single block reads dominate the running time. On average, they are quick to 0.001 seconds (1 ms), but many of them are. What is the buffer cache?

    * The SQL statement uses the predicates like this WHERE clause: "F123_AR_NR > = ' F123_AR_NR «»<=", which="" i="" believe="" would="" be="" treated="" differently="" in="" cardinality="" calculations="" (2="" unbounded="" ranges)when="" compared="" to="" a="" where="" clause="" that="" uses="" between="" syntax="" (a="" single="" bounded="" range).="" the="" query="" optimizer="" will="" actually="" transform="" the="" between="" syntax="" into="" two="" unbounded="" ranges,="" but="" if="" i="" remember="" correctly,="" it="" will="" remember="" that="" the="" ranges="" are="" bounded="" when="" performing="" the="" cardinality="">

    * The DBMS_XPLAN. DISPLAY_CURSOR output shows that the number of blocks read from disk is 13 531 but you get only 11 104 consistent. The number of physical blocks read must be generally less number of becomes coherent. If I remember correctly, the number of readings of physical blocks can be higher if index preloading takes place, or if the intermediate results must be written for the temp tablespace. In this case, it seems that the index preloading takes place.

    * It seems that because this query has been run at least 3 times in succession fast, already read of the disk blocks should remain in the buffer cache. This suggests that the buffer cache is too small. Are the BH123GH table and its indexes defined to use the buffer pool KEEP or RECYCLE, yet these buffer pools are not defined?

    Charles Hooper
    http://hoopercharles.WordPress.com/
    IT Manager/Oracle DBA
    K & M-making Machine, Inc.

  • How to see the info of waiting events. After executing a statement select query

    Hello

    How to see the info of waiting events. After running a select query. Is there a setting to the value of this option?
    And I also want to see the following info. in the trace file. For this, what are the settings I need to adjust to the right?
    SELECT * FROM emp, dept 
    WHERE emp.deptno = dept.deptno;
    
    call   count      cpu    elapsed     disk    query current    rows
    ---- -------  -------  --------- -------- -------- -------  ------
    Parse      1     0.16      0.29         3       13       0       0
    Execute    1     0.00      0.00         0        0       0       0
    Fetch      1     0.03      0.26         2        2       4      14 
     
    Misses in library cache during parse: 1 
    Parsing user id: (8) SCOTT 
    Concerning
    Evelyne

    For

    SQL > show parameter dump;

    ORA-00942: table or view does not exist
    >
    Use

     GRANT SEECT ON v_$parameter to Your_User_Name
    

    For

    SQL > ALTER SESSION SET EVENTS = 10046 trace name forever, context level 12';

    ERROR:
    ORA-01031: insufficient privileges
    >
    Use

     GRANT ALTER SESSION to your_user
    
  • Query taking forever.

    Hello

    I have a query to be run by an application (it generates the actual query and execute it) which takes 1 hour or more*.

    I try the same me (sql developer), the only difference is I have replace the variables of space booked by values and this quick true course (1 to 2 seconds).

    I try the same query through the application in my test DB but it runs very fast.

    I go back and here is the result.

    A few days ago, it was beautiful. I tried to bounce the DB without change. Nothing strange that I can see in the alerts log.

    The number of requests for the fetch below line is huge (19469112), and also the lines plan execution on one of the last lines (index POP_REQUISITION_LINES_VN, lines = 41553286)

    Can someone give me a clue as to what is happening?
    I can try to delete the index, run the program again and see (I have a feeling I'll have to add the new index if)?

    **********************************************************************
    SELECT A1.ROWID,A2.ROWID,A3.ROWID 
    FROM
     IRMFIN.POP_REQUISITION_HEADERS A1,IRMFIN.POP_REQUISITION_LINES A2,
      IRMFIN.POP_REQUISITION_LINE_DETAILS A3 WHERE ((((((((((((A1.COMPANY_CODE=:1 
      AND A1.DIVISION=:2) AND A2.COMPANY_CODE=A1.COMPANY_CODE) AND A2.DIVISION=
      A1.DIVISION) AND A2.REQUISITION_NUMBER=A1.REQUISITION_NUMBER) AND 
      A2.REQUISITION_STATUS_FLAG=:5) AND A2.REQ_RUN_NUMBER=:6) AND A2.BUYER_CODE=
      :16) AND A2.POP_SEND_TO_BT_FLAG=:13) AND A3.COMPANY_CODE=A2.COMPANY_CODE) 
      AND A3.DIVISION=A2.DIVISION) AND A3.REQUISITION_NUMBER=
      A2.REQUISITION_NUMBER) AND A3.REQ_LINE_NUMBER=A2.REQ_LINE_NUMBER) AND 
      A3.ROWID IN (SELECT MIN(A3.ROWID) FROM IRMFIN.POP_REQUISITION_HEADERS A1,
      IRMFIN.POP_REQUISITION_LINES A2,IRMFIN.POP_REQUISITION_LINE_DETAILS A3 
      WHERE ((((((((((((A1.COMPANY_CODE=:1 AND A1.DIVISION=:2) AND 
      A2.COMPANY_CODE=A1.COMPANY_CODE) AND A2.DIVISION=A1.DIVISION) AND 
      A2.REQUISITION_NUMBER=A1.REQUISITION_NUMBER) AND A2.REQUISITION_STATUS_FLAG=
      :5) AND A2.REQ_RUN_NUMBER=:6) AND A2.BUYER_CODE=:16) AND 
      A2.POP_SEND_TO_BT_FLAG=:13) AND A3.COMPANY_CODE=A2.COMPANY_CODE) AND 
      A3.DIVISION=A2.DIVISION) AND A3.REQUISITION_NUMBER=A2.REQUISITION_NUMBER) 
      AND A3.REQ_LINE_NUMBER=A2.REQ_LINE_NUMBER) GROUP BY A3.REQUISITION_NUMBER,
      A3.REQ_LINE_NUMBER,A3.LINE_SEQUENCE) AND A2.ROWID IN (SELECT MIN(A2.ROWID) 
      FROM IRMFIN.POP_REQUISITION_LINES A2 WHERE (((A2.REQUISITION_STATUS_FLAG=:5 
      AND A2.REQ_RUN_NUMBER=:6) AND A2.BUYER_CODE=:16) AND A2.POP_SEND_TO_BT_FLAG=
      :13) GROUP BY REQ_LINE_NUMBER,REQUISITION_NUMBER,DIVISION,COMPANY_CODE) 
      ORDER BY A2.BUYER_CODE ASC,A2.REQUISITION_NUMBER ASC,A2.REQ_LINE_NUMBER ASC
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.14       0.13          0          0          0           0
    Fetch        1     65.12      26.70          3   19469112          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        3     65.26      26.84          3   19469112          0           0
    
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 63  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          0  SORT ORDER BY (cr=0 pr=0 pw=0 time=78 us)
          0   NESTED LOOPS  (cr=0 pr=0 pw=0 time=70 us)
          1    NESTED LOOPS  (cr=147 pr=2 pw=0 time=19824 us)
          1     NESTED LOOPS  (cr=145 pr=2 pw=0 time=19803 us)
          1      VIEW  VW_NSO_1 (cr=144 pr=2 pw=0 time=19782 us)
          1       HASH UNIQUE (cr=144 pr=2 pw=0 time=19780 us)
        122        HASH GROUP BY (cr=144 pr=2 pw=0 time=18934 us)
        122         TABLE ACCESS BY INDEX ROWID POP_REQUISITION_LINES (cr=144 pr=2 pw=0 time=19575 us)
        266          INDEX RANGE SCAN POP_REQUISITION_LINES_STATF (cr=2 pr=2 pw=0 time=17117 us)(object id 1768749)
          1      TABLE ACCESS BY USER ROWID POP_REQUISITION_LINES (cr=1 pr=0 pw=0 time=17 us)
          1     INDEX UNIQUE SCAN POP_REQUISITION_HEADERS (cr=2 pr=0 pw=0 time=19 us)(object id 54788)
          0    INDEX RANGE SCAN POP_REQUISITION_LINE_DETAILS (cr=0 pr=0 pw=0 time=5 us)(object id 54790)
          0     FILTER  (cr=0 pr=0 pw=0 time=18 us)
          0      SORT GROUP BY NOSORT (cr=0 pr=0 pw=0 time=16 us)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=7 us)
          0        NESTED LOOPS  (cr=0 pr=0 pw=0 time=5 us)
        599         INDEX RANGE SCAN POP_REQUISITION_LINE_DETAILS (cr=7 pr=0 pw=0 time=1212 us)(object id 54790)
          0         TABLE ACCESS BY INDEX ROWID POP_REQUISITION_LINES (cr=19445166 pr=0 pw=0 time=65092442 us)
    41553286          INDEX RANGE SCAN POP_REQUISITION_LINES_VN (cr=128134 pr=0 pw=0 time=10435 us)(object id 477588)
          0        INDEX UNIQUE SCAN POP_REQUISITION_HEADERS (cr=0 pr=0 pw=0 time=0 us)(object id 54788)
    ********************************************************************************

    Published by: BluShadow on March 29, 2011 15:55
    addition of {noformat}
    {noformat} tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    Some reflections on the data you present:

    -Column statistics are present since your explain plan command showed 9912 lines that approximates the number of rows divided by the number of distinct values.

    -Histograms appear to present since your plan changed after a rebound in the database. This is probably due to bind variable peeking. The first execution after the bounce had a look at the variable binding and I saw status_flag "PO STUDENT." Cost based optimizer has decided that index STATF was not good to use and used the VN index.

    Possible solutions:

    -Get rid of the histogram on the column status_flag

    -Index of your query in order to always use the index STATF

    -The above two will create a better plan, but not optimal plan (might be pretty good, however). You can create a better index for this query on the columns you see in the main section of your plan to explain, lines 17 and 18.

    I hope this helps.

    Kind regards
    Rob.

  • SQL Query Execute County tkprof

    Hi all

    I have the query that is slow.
    SELECT MAX(ID) FROM ID_TAB WHERE R_ID = :B1 
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        0      0.00       0.00          0          0          0           0
    Execute 649574    117.93     127.29          0          0          0           0
    Fetch   649574     20.40      20.85          0    1948722          0      649574
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total   1299148    138.33     148.14          0    1948722          0      649574
    
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 65     (recursive depth: 2)
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      cursor: pin S wait on X                       133        0.03          2.13
      cursor: pin S                                1179        0.00          0.01
      
    I know that this may be a bug or something else. But I have another question, then this

    Why is he running count so much. I think that run County increase when you DML? If this is not the case, what are the other scenerios where it can increase run County.

    Nico wrote:
    Thanks for the reply. Another instance

    The index is here:

    recursive depth: 2
    

    * SQL executed directly by a user runs in the recursive depth: 0
    * SQL in a PL/SQL procedure called by SQL run directly by a user runs in the recursive depth: 1
    * SQL executed within a trigger that executes automatically in response to SQL run directly by a user runs in the recursive depth: 1
    * SQL executed directly by a user who calls a PL/SQL procedure that then causes a trigger is a way to get a recursive depth: 2
    * SQL executed directly by a user who calls a PL/SQL procedure that then calls a second PL/SQL procedure is another way to get a recursive depth: 2

    Possible cause: suppose you have a trigger that fires at each change of rank. A user session wishes to insert a large number of rows into a table, then it calls a PL/SQL procedure to handle the task. The PL/SQL procedure running insert statements, and after each insert statement is triggered, a trigger is activated for the sequential number next to a column in the table (or a separate record) by running "SELECT MAX (ID) OF ID_TAB WHERE R_ID =: B1" in the database.

    Charles Hooper
    Co-author of "Expert Oracle practices: Oracle Database Administration of the Oak Table.
    http://hoopercharles.WordPress.com/
    IT Manager/Oracle DBA
    K & M-making Machine, Inc.

  • Slow index by using the query. Fast with full table Scan.

    Salvation;

    (Thanks for the links)

    Here's my question correctly formatted.

    The query:
    SELECT count(1)
    from ehgeoconstru  ec 
    where ec.TYPE='BAR'  
    AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') )   
    and deathdate is null 
    and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
    Works on 32 seconds!


    Same query, but with an extra where clause:
    SELECT count(1)
    from ehgeoconstru  ec 
    where ec.TYPE='BAR'  
    and  ( (ec.contextVersion = 'REALWORLD')     --- ADDED HERE
    AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) )  
    and deathdate is null 
    and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
    This is 400 seconds.

    It should return data from a table, given the conditions.

    The database version is Oracle9i Release 9.2.0.7.0

    These are the parameters relevant for the optimizer:
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling           integer     1
    optimizer_features_enable            string      9.2.0
    optimizer_index_caching              integer     99
    optimizer_index_cost_adj             integer     10
    optimizer_max_permutations           integer     2000
    optimizer_mode                       string      CHOOSE
    
    SQL> 
    Here is the output of the PLAN to EXPLAIN for the first quick query:
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    
    --------------------------------------------------------------------------------
    | Id  | Operation                     |  Name               | Rows  | Bytes | Cost  |
    --------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |                         |           |       |       |
    |   1 |  SORT AGGREGATE       |                         |           |       |       |
    |*  2 |   TABLE ACCESS FULL   | EHCONS            |       |       |       |
    --------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    
       2 - filter(SUBSTR("EC"."strgfd",1,8)<>'[CIMText' AND "EC"."DEATHDATE"
                  IS NULL AND "EC"."BIRTHDATE"<=TO_DATE('2009-10-06 11:52:12', 'yyyy
    -mm-dd
    
                  hh24:mi:ss') AND "EC"."TYPE"='BAR')
    
    Note: rule based optimization
    Here is the output of the EXPLAIN of PLAN for slow queries:
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
       |       |
    
    |   1 |  SORT AGGREGATE              |                             |       |
       |       |
    
    |*  2 |   TABLE ACCESS BY INDEX ROWID| ehgeoconstru      |       |
       |       |
    
    |*  3 |    INDEX RANGE SCAN          | ehgeoconstru_VSN  |       |
       |       |
    
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    2 - filter(SUBSTR("EC"."strgfd",1,8)<>'[CIMText' AND "EC"."DEATHDATE" IS
     NULL AND "EC"."TYPE"='BAR')
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
       3 - access("EC"."CONTEXTVERSION"='REALWORLD' AND "EC"."BIRTHDATE"<=TO_DATE('2
    009-10-06
    
                  11:52:12', 'yyyy-mm-dd hh24:mi:ss'))
           filter("EC"."BIRTHDATE"<=TO_DATE('2009-10-06 11:52:12', 'yyyy-mm-dd hh24:
    mi:ss'))
    
    
    Note: rule based optimization
    The TKPROF output for this slow statement is:
    TKPROF: Release 9.2.0.7.0 - Production on Tue Nov 17 14:46:32 2009
    
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    
    Trace file: gen_ora_3120.trc
    Sort options: prsela  exeela  fchela  
    ********************************************************************************
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing 
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    ********************************************************************************
    
    SELECT count(1)
    from ehgeoconstru  ec
    where ec.TYPE='BAR'
    and  ( (ec.contextVersion = 'REALWORLD')
    AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) )
    and deathdate is null
    and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.00     538.12     162221    1355323          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4      0.00     538.12     162221    1355323          0           1
    
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 153  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          1  SORT AGGREGATE 
      27747   TABLE ACCESS BY INDEX ROWID OBJ#(73959) 
    2134955    INDEX RANGE SCAN OBJ#(73962) (object id 73962)
    
    ********************************************************************************
    
    alter session set sql_trace=true
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.02          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        1      0.00       0.02          0          0          0           0
    
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    Optimizer goal: CHOOSE
    Parsing user id: 153  
    
    
    
    ********************************************************************************
    
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.02          0          0          0           0
    Fetch        2      0.00     538.12     162221    1355323          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        5      0.00     538.15     162221    1355323          0           1
    
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    
    
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        0      0.00       0.00          0          0          0           0
    Execute      0      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        0      0.00       0.00          0          0          0           0
    
    Misses in library cache during parse: 0
    
        2  user  SQL statements in session.
        0  internal SQL statements in session.
        2  SQL statements in session.
    ********************************************************************************
    Trace file: gen_ora_3120.trc
    Trace file compatibility: 9.02.00
    Sort options: prsela  exeela  fchela  
           2  sessions in tracefile.
           2  user  SQL statements in trace file.
           0  internal SQL statements in trace file.
           2  SQL statements in trace file.
           2  unique SQL statements in trace file.
          94  lines in trace file.
    Published by: PauloSMO on November 17, 2009 04:21

    Published by: PauloSMO on November 17, 2009 07:07

    Published by: PauloSMO on November 17, 2009 07:38 - title changed to be more correct.

    Although your optimizer_mode is choosing, it seems that there are no statistics collected on ehgeoconstru. The absence of estimated costs and estimated row counts of each of the stages of the plan and the "Note: optimization based on rules" at the end of these two plans would tend to confirm this.

    Optimizer_mode choose means that if statistics are collected then it will use the CBO, but if no statistic is present in any of the tables in the query, the optimizer to rule will be used. The RBO tends to be happy in the best of the index case. I guess the index ehgeoconstru_VSN contextversion as the main column and also includes the date of birth.

    You can either gather statistics on the table (if all other tables have statistics) using dbms_stats.gather_table_stats, or suggest the query to use a full scan instead of index. Another solution would be to apply a function or an operation against the contextversion to prevent the use of the index. something like this:

    SELECT COUNT(*)
    FROM ehgeoconstru  ec
    WHERE ec.type='BAR' and
          ec.contextVersion||'' = 'REALWORLD'
          ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') and
          deathdate is null and
          SUBSTR(ec.strgfd, 1, LENGTH('[CIMText')) <> '[CIMText'
    

    or maybe UPPER (ec.contextVersion) so that would not change the rows returned.

    John

  • long-term query work - included steps proposed by Randolf

    Hello

    I did my best to follow the statement Randolf Word-by-Word and hope to get the solution for my
    problem soon. Sometimes back, I posted a thread about this problem then occupied with others
    stuff and wasn't able to follow. Here I am again with the same question.

    Here's the link to my previous post
    long running query in database 10g
    Here is the bottom of my requriemment.

    I'm working on Oracle forms 10g, which uses the package below. We want to display the information about the customer
    with order County ADB on different status as pending, error, back-Order, expedited, shipping of std.
    Output will look like.
    client name   pending    error   backorder   expedited   std shipping
    ABC            24         0       674          6789         78900
    XYZ            35         673    5700           0           798274
    .
    .
    .
    There are 40 customers total. The long-running query are accelerated and the delivery of std.


    When I run the package of Oracle Developer of shape, it takes 3 minutes to run but when I run the same query in our application using forms
    (who uses Oracle Application Server) it takes about 1 hour, which is totally unacceptable.
    The user wants it be done in less than 1 minute.

    I tried to combine together in the waiting, error and out of stock of queries, but AFAIK this is not
    work in the form of Oracle that we need a placeholder for each situation.

    Please don't think this is the related issue of forms, it's a performance problem.

    PACKAGE BODY ORDER_COUNT_PKG IS
      
     PROCEDURE post_query IS
      
      BEGIN
                     
           BEGIN
                SELECT count(*)
                  INTO :ORDER_STATUS.PENDING
                  FROM orders o
              WHERE o.status = 'P'
                   AND (parent_order_id is null
                    OR  (order_type='G' 
                         AND parent_order_id=original_order_number))
                      AND  o.client = :ORDER_STATUS.CLIENT_NUMBER;
                      
         EXCEPTION
           WHEN OTHERS THEN
           NULL;
           END;
           
             BEGIN
                 SELECT  count(*)
                   INTO  :ORDER_STATUS.ERROR
                   FROM  orders o
                  WHERE  o.status = 'E'
                    AND  (parent_order_id is null
                     OR  (order_type='G' 
                           AND parent_order_id=original_order_number))
                       AND  o.client = :ORDER_STATUS.CLIENT_NUMBER;
                       
                EXCEPTION
           WHEN OTHERS THEN
           NULL;     
            
            END;
    
    
           BEGIN
                SELECT count(*)
                  INTO :ORDER_STATUS.BACK_ORDER
                  FROM orders o
              WHERE o.status = 'B'
                   AND (parent_order_id is null
                    OR (order_type='G' 
                         AND parent_order_id=original_order_number))
                      AND o.client = :ORDER_STATUS.CLIENT_NUMBER;
                      
          EXCEPTION
           WHEN OTHERS THEN
           NULL;    
           
         END;
                
           BEGIN
                SELECT count(*)
                  INTO :ORDER_STATUS.EXPEDITE
                  FROM orders o,shipment_type_methods stm
                 WHERE o.status in ('A','U')
             AND (o.parent_order_id is null
              OR (o.order_type = 'G'
             AND o.parent_order_id = o.original_order_number))
             AND o.client = stm.client
             AND o.shipment_class_code = stm.shipment_class_code
             AND (nvl(o.priority,'1') = '2'
              OR  stm.surcharge_amount <> 0)
                      AND  o.client = :ORDER_STATUS.CLIENT_NUMBER
              GROUP BY  o.client;
              
              EXCEPTION
           WHEN OTHERS THEN
           NULL;          
           
          END;           
           
     
           BEGIN
                SELECT count(*)
                  INTO :ORDER_STATUS.STD_SHIP
                  FROM  orders o,shipment_type_methods stm
                 WHERE o.status in ('A','U')
             AND  (o.parent_order_id is null
              OR (o.order_type = 'G'
             AND o.parent_order_id = o.original_order_number))
             AND nvl(o.priority,'1') <> '2'
             AND o.client = stm.client 
             AND o.shipment_class_code = stm.shipment_class_code
             AND stm.surcharge_amount = 0
                      AND o.client = :ORDER_STATUS.CLIENT_NUMBER
              GROUP BY o.client;
              
          EXCEPTION
           WHEN OTHERS THEN
           NULL;
           
           END;
     
      END post_query; 
      END ORDER_COUNT_PKG;
    the query that takes a long time is
    SELECT count(*)
                   FROM  orders o,shipment_type_methods stm
                 WHERE o.status in ('A','U')
             AND  (o.parent_order_id is null
              OR (o.order_type = 'G'
             AND o.parent_order_id = o.original_order_number))
             AND nvl(o.priority,'1') <> '2'
             AND o.client = stm.client 
             AND o.shipment_class_code = stm.shipment_class_code
             AND stm.surcharge_amount = 0
               AND o.client = :CLIENT_NUMBER
              GROUP BY o.client
    The version of the database is 10.2.1.0.2
    SQL> alter session force parallel dml;
    These are the parameters relevant for the optimizer:
    SQL> show parameter user_dump_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    user_dump_dest                       string      /u01/app/oracle/admin/mcgemqa/
                                                     udump
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.4
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    SQL> show parameter db_file_multi
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count        integer     16
    SQL> show parameter db_block_size
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_block_size                        integer     8192
    SQL> show parameter cursor_sharing
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing                       string      EXACT
    Here is the output of the EXPLAIN PLAN of:
    SQL> explain plan for
      2  SELECT count(*)
      3         FROM  orders o,shipment_type_methods stm
      4       WHERE o.status in ('A','U')
      5           AND  (o.parent_order_id is null
      6            OR (o.order_type = 'G'
      7           AND o.parent_order_id = o.original_order_number))
      8           AND nvl(o.priority,'1') <> '2'
      9           AND o.client = stm.client 
     10           AND o.shipment_class_code = stm.shipment_class_code
     11           AND stm.surcharge_amount = 0
     12     AND o.client = :CLIENT_NUMBER
     13    GROUP BY o.client
     14  /
    
    Explained.
    
    Elapsed: 00:00:00.12
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------
    Plan hash value: 559278019
    
    ----------------------------------------------------------------------------------------------------
    | Id  | Operation                      | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT               |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |   1 |  SORT GROUP BY NOSORT          |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | ORDERS                  |   175K|  3431K| 25979   (3)| 00:05:12 |
    |   3 |    NESTED LOOPS                |                         | 25300 |   864K| 46764   (3)| 00:09:22 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |     1 |    15 |     2   (0)| 00:00
    |*  5 |      INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |     2 |       |     1   (0)| 00:00:01 |
    |*  6 |     INDEX RANGE SCAN           | ORDERS_ORDER_DATE       |   176K|       |  2371   (8)| 00:00:29 |
    ----------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
                  AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
       4 - filter("STM"."SURCHARGE_AMOUNT"=0)
       5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
       6 - access("O"."CLIENT"=:CLIENT_NUMBER)
           filter("O"."STATUS"='A' OR "O"."STATUS"='U')
    
    24 rows selected.
    
    Elapsed: 00:00:00.86
    SQL> rollback;
    
    Rollback complete.
    
    Elapsed: 00:00:00.07
    Here is the output of SQL * Plus AUTOTRACE, including CALENDAR information:
    SQL> SELECT count(*)
      2         FROM  orders o,shipment_type_methods stm
      3       WHERE o.status in ('A','U')
      4           AND  (o.parent_order_id is null
      5            OR (o.order_type = 'G'
      6           AND o.parent_order_id = o.original_order_number))
      7           AND nvl(o.priority,'1') <> '2'
      8           AND o.client = stm.client 
      9           AND o.shipment_class_code = stm.shipment_class_code
     10           AND stm.surcharge_amount = 0
     11     AND o.client = :CLIENT_NUMBER
     12    GROUP BY o.client
     13  /
    
    Elapsed: 00:00:03.09
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 559278019
    
    ----------------------------------------------------------------------------------------------------
    | Id  | Operation                      | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT               |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |   1 |  SORT GROUP BY NOSORT          |                         |     1 |    35 | 46764   (3)| 00:09:22 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | ORDERS                  |   175K|  3431K| 25979   (3)| 00:05:12 |
    |   3 |    NESTED LOOPS                |                         | 25300 |   864K| 46764   (3)| 00:09:22 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |     1 |    15 |     2   (0)| 00:00
    |*  5 |      INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |     2 |       |     1   (0)| 00:00:01 |
    |*  6 |     INDEX RANGE SCAN           | ORDERS_ORDER_DATE       |   176K|       |  2371   (8)| 00:00:29 |
    ----------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
                  AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
       4 - filter("STM"."SURCHARGE_AMOUNT"=0)
       5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
       6 - access("O"."CLIENT"=:CLIENT_NUMBER)
           filter("O"."STATUS"='A' OR "O"."STATUS"='U')
    
    
    Statistics
    ----------------------------------------------------------
             55  recursive calls
              0  db block gets
           7045  consistent gets
              0  physical reads
              0  redo size
            206  bytes sent via SQL*Net to client
            238  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> 
    The TKPROF output for that statement looks like the following:
    SELECT count(*)
           FROM  orders o,shipment_type_methods stm
         WHERE o.status in ('A','U')
             AND  (o.parent_order_id is null
              OR (o.order_type = 'G'
             AND o.parent_order_id = o.original_order_number))
             AND nvl(o.priority,'1') <> '2'
             AND o.client = stm.client
             AND o.shipment_class_code = stm.shipment_class_code
             AND stm.surcharge_amount = 0
       AND o.client = :CLIENT_NUMBER
      GROUP BY o.client
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.04       0.04          0          0          0           0
    Fetch        2      2.96       2.91          0       7039          0           1
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4      3.01       2.95          0       7039          0           1
    
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 95  
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          1  SORT GROUP BY NOSORT (cr=7039 pr=0 pw=0 time=2913701 us)
         91   TABLE ACCESS BY INDEX ROWID ORDERS (cr=7039 pr=0 pw=0 time=261997906 us)
         93    NESTED LOOPS  (cr=6976 pr=0 pw=0 time=20740 us)
          1     TABLE ACCESS BY INDEX ROWID SHIPMENT_TYPE_METHODS (cr=2 pr=0 pw=0 time=208 us)
          3      INDEX RANGE SCAN U_SHIPMENT_TYPE_METHODS (cr=1 pr=0 pw=0 time=88 us)(object id 81957)
         91     INDEX RANGE SCAN ORDERS_ORDER_DATE (cr=6974 pr=0 pw=0 time=70 us)(object id 81547)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      SQL*Net message from client                     2        0.02          0.02
    ********************************************************************************
    DBMS_XPLAN. Output DISPLAY_CURSOR:
    SQL> variable CLIENT_NUMBER varchar2(20) 
    SQL> exec :CLIENT_NUMBER := '14'
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.06
    SQL> SELECT /*+ gather_plan_statistics */ count(*)
      2         FROM  orders o,shipment_type_methods stm
      3       WHERE o.status in ('A','U')
      4           AND  (o.parent_order_id is null
      5            OR (o.order_type = 'G'
      6           AND o.parent_order_id = o.original_order_number))
      7           AND nvl(o.priority,'1') <> '2'
      8           AND o.client = stm.client 
      9           AND o.shipment_class_code = stm.shipment_class_code
     10           AND stm.surcharge_amount = 0
     11     AND o.client = :CLIENT_NUMBER
     12    GROUP BY o.client
     13  /
    
      COUNT(*)
    ----------
            91
    
    Elapsed: 00:00:02.85
    SQL> set termout on
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------
    SQL_ID  4nfj368y8w6a3, child number 0
    -------------------------------------
    SELECT /*+ gather_plan_statistics */ count(*)        FROM  orders o,shipment_type_methods stm      WHERE
    o.status in ('A','U')          AND  (o.parent_order_id is null           OR (o.order_type = 'G'
    AND o.parent_order_id = o.original_order_number))          AND nvl(o.priority,'1') <> '2'          AND
    o.client = stm.client          AND o.shipment_class_code = stm.shipment_class_code          AND
    stm.surcharge_amount = 0    AND o.client = :CLIENT_NUMBER   GROUP BY o.client
    
    Plan hash value: 559278019
    
    ----------------------------------------------------------------------------------------------------
    | Id  | Operation                      | Name                    | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    ----------------------------------------------------------------------------------------------------
    |   1 |  SORT GROUP BY NOSORT          |                         |      1 |      1 |      1 |00:00:02.63 |    7039 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID  | ORDERS                  |      1 |    175K|     91 |00:03:56.87 |    7039 |
    |   3 |    NESTED LOOPS                |                         |      1 |  25300 |     93 |00:00:00.02 |    6976 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS   |      1 |      1 |      1 |00:00:00.01 |       2 |
    |*  5 |      INDEX RANGE SCAN          | U_SHIPMENT_TYPE_METHODS |      1 |      2 |      3 |00:00:00.01 |       1 |
    |*  6 |     INDEX RANGE SCAN           | ORDERS_ORDER_DATE       |      1 |    176K|     91 |00:00:00.01 |    6974 |
    ----------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter((("O"."PARENT_ORDER_ID" IS NULL OR ("O"."ORDER_TYPE"='G' AND
                  "O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER"))) AND NVL("O"."PRIORITY",'1')<>'
                  "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE"))
       4 - filter("STM"."SURCHARGE_AMOUNT"=0)
       5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
       6 - access("O"."CLIENT"=:CLIENT_NUMBER)
           filter(("O"."STATUS"='A' OR "O"."STATUS"='U'))
    
    
    32 rows selected.
    
    Elapsed: 00:00:01.30
    SQL> 
    I can't wait for suggestions to improve the performance of this statement.


    Thank you
    Sandy

    OK Sandy, progress. It is now 'down' to 30 minutes just because you are only running a query in this form, not five or three, but it's still about 29 minutes and 57 seconds longer that he should take. You will see results of the above query you posted, that all WAIT events are ' SQL * Net client message ', which means that the database server is waiting for communication from the application server. Some massive waits, one of 2 290 696 seconds, which is equal to 26 days! It could be someone who has logged, but now gone on vacation. Recognize a name of machine, where it is the Ap Server?

    But you know now that your query will be executed quickly, and I'm not sure what OEM recommended implementation plan, he could only use a Scan of full Table instead of an analysis of index range on orders, which would make sense since you are now picking up five statuses of command where before you were only picking up 3 or 2 in each SELECTION. So, is not a problem per se database, it is a problem of the Ap server and from there you could better raise the problem in this subforum: Business Intelligence Applications and it may well be interesting to try that I proposed yesterday to clone among other forms of 'good' and just Exchange procedures. Good luck with it!

Maybe you are looking for

  • How to hide the photos in my iPhone 6 more?

    Hello Apple! I searched for tutorials on how to hide the photos in my "Photos" application They say that, I will select a photo, then press on hold... then action will pop up with the options "Copy" and "hide". To do this, do not show the "copy" and

  • run the command VI OPC without OPC

    Hi all I develop a VI for use with a mutual FUND. Because the installation is no place for the development of client software, I brought the PC with Labview & OPC to my office where I want to develop the VI. Here the facility is not connected to the

  • Windows server 2012r2 essentials for datacenter

    As the title, is Hi possible to convert the essentials of windows server 2012 r2 Datacenter? I received a key from one of my friends and I want to activate it, but I don't know if this is possible. Thanks for help/read!

  • Problem printer Brother DCP-7065DN

    My modem died earlier this week, and since the replacement, my printer does not print.  I tried all the troubleshooting but nothing has changed.  The printer is not listed in Device Manager.  Help would be greatly appreciated!

  • Z3 HDCP error with Microsoft display adapter (Miracast)

    I have a brand new Z3 with the original image and it does not work with the wireless display adapter Microsoft (miracast). The Z3 detects the device and tries to connect for a few seconds. After that, it gives the following error, "could not turn on