Reduce execution time with selects

Hi,
I have to reduce the execution time in a report, most of the consumed time is in the select query.
I have a table, gt_result:
DATA: BEGIN OF gwa_result,
      tknum            LIKE vttk-tknum,
      stabf            LIKE vttk-stabf,
      shtyp            LIKE vttk-shtyp,
      route            LIKE vttk-route,
      vsart            LIKE vttk-vsart,
      signi            LIKE vttk-signi,
      dtabf            LIKE vttk-dtabf,
      vbeln            LIKE likp-vbeln,
      /bshm/le_nr_cust LIKE likp-/bshm/le_nr_cust,
      vkorg            LIKE likp-vkorg,
      werks            LIKE likp-werks,
      regio            LIKE kna1-regio,
      land1            LIKE kna1-land1,
      xegld            LIKE t005-xegld,
      intca            LIKE t005-intca,
      bezei            LIKE tvrot-bezei,
      bezei1           LIKE t173t-bezei,
      fecha(10) type c.
DATA: END OF gwa_result.
DATA: gt_result LIKE STANDARD TABLE OF gwa_result.
And the select query is this:
  SELECT ktknum kstabf kshtyp kroute kvsart ksigni
k~dtabf
         lvbeln l/bshm/le_nr_cust lvkorg lwerks   nregio nland1 oxegld ointca
             tbezei   ttbezei
  FROM vttk AS k
  INNER JOIN vttp  AS p ON ktknum = ptknum
  INNER JOIN likp  AS l ON pvbeln = lvbeln
  INNER JOIN kna1  AS n ON lkunnr = nkunnr
  INNER JOIN t005  AS o ON nland1 = oland1
  INNER JOIN tvrot AS t ON troute = kroute AND t~spras = sy-langu
  INNER JOIN t173t AS tt ON ttvsart = kvsart AND tt~spras = sy-langu
  INTO TABLE gt_result
  WHERE ktknum IN s_tknum AND ktplst IN s_tplst AND k~route IN s_route AND
     k~erdat BETWEEN s_erdat-low AND s_erdat-high AND
     l~/bshm/le_nr_cust <> ' '    "IS NOT NULL
     AND k~stabf = 'X'
     AND ktknum NOT IN ( SELECT tktknum  FROM vttk AS tk
                         INNER JOIN vttp AS tp ON tktknum = tptknum
                         INNER JOIN likp AS tl ON tpvbeln = tlvbeln
                         WHERE l~/bshm/le_nr_cust IS NULL )
     AND k~tknum NOT IN ( SELECT tknum FROM /bshs/ssm_eship )
     AND ( o~xegld = ' '
           OR ( o~xegld = 'X' AND
                ( ( n~land1 = 'ES'
                    AND ( nregio = '51' OR nregio = '52'
                          OR nregio =  '35' OR nregio =  '38' ) )
                           OR n~land1 = 'ESC' ) )
                  OR ointca = 'AD' OR ointca = 'GI' ).
Does somebody know how to reduce the execution time ?.
Thanks.

Hi,
Try to remove the join. Use seperate selects as shown in example below and for the sake of selection, keep some key fields in your internal table.
Then once your final table is created, you can copy the table into GT_FINAL which will contain only fields you need.
EX
data : begin of it_likp occurs 0,
         vbeln like likp-vbeln,
         /bshm/le_nr_cust like likp-/bshm/le_nr_cust,
         vkorg like likp-vkorg,
         werks like likp-werks,
         kunnr likr likp-kunnr,
       end of it_likp.
data : begin of it_kna1 occurs 0,
       kunnr like...
       regio....
       land1...
      end  of it_kna1 occurs 0,
Select tknum stabf shtyp route vsart signi dtabf
from VTTP
into table gt_result
WHERE tknum IN s_tknum AND
      tplst IN s_tplst AND
      route IN s_route AND
      erdat BETWEEN s_erdat-low AND s_erdat-high.
select vbeln /bshm/le_nr_cust
       vkorg werks kunnr
       from likp
       into table it_likp
       for all entries in gt_result
       where vbeln = gt_result-vbeln.
select kunnr
       regio
       land1
       from kna1
       into it_kna1
       for all entries in it_likp.
similarly for other tables.
Then loop at gt result and read corresponding table and populate entire record :
loop at gt_result.
read table it_likp where vbeln = gt_result-vbeln.
if sy-subrc eq 0.
  move corresponding fields of it_likp into gt_result.
  gt_result-kunnr = it_likp-kunnr.
  modify gt_result.
endif.
read table it_kna1 where kunnr = gt_result-vbeln.
if sy-subrc eq 0.
  gt_result-regio = it-kna1-regio.
  gt_result-land1 = it-kna1-land1.
  modify gt_result.
endif.
endloop.

Similar Messages

  • How to reduce execution time ?

    Hi friends...
    I have created a report to display vendor opening balances,
    total debit ,total credit , total balance & closing balance for the given date range. it is working fine .But it takes more time to execute . How can I reduce execution time ?
    Plz help me. It's a very urgent report...
    The coding is as below.....
    report  yfiin_rep_vendordetail no standard page heading.
    tables : bsik,bsak,lfb1,lfa1.
    type-pools : slis .
    --TABLE STRUCTURE--
    types : begin of tt_bsik,
            bukrs type bukrs,
            lifnr type lifnr,
            budat type budat,
            augdt type augdt,
            dmbtr type dmbtr,
            wrbtr type wrbtr,
            shkzg type shkzg,
            hkont type hkont,
            bstat type bstat_d ,
            prctr type prctr,
            name1 type name1,
         end of tt_bsik,
         begin of tt_lfb1,
             lifnr type lifnr,
             mindk type mindk,
         end of tt_lfb1,
        begin of tt_lfa1,
            lifnr type lifnr,
            name1 type name1,
            ktokk type ktokk,
        end of tt_lfa1,
        begin of tt_opbal,
            bukrs type bukrs,
            lifnr type lifnr,
            gjahr type gjahr,
            belnr type belnr_d,
            budat type budat,
            bldat type bldat,
            waers type waers,
            dmbtr type dmbtr,
            wrbtr type wrbtr,
            shkzg type shkzg,
            blart type blart,
            monat type monat,
            hkont type hkont,
            bstat type bstat_d ,
            prctr type prctr,
            name1 type name1,
            tdr type  dmbtr,
            tcr type  dmbtr,
            tbal type  dmbtr,
          end of tt_opbal,
         begin of tt_bs ,
            bukrs type bukrs,
            lifnr type lifnr,
            name1 type name1,
            prctr type prctr,
            tbal type dmbtr,
            bala type dmbtr,
            balb type dmbtr,
            balc type dmbtr,
            bald type dmbtr,
            bale type dmbtr,
            gbal type dmbtr,
        end of tt_bs.
    ************WORK AREA DECLARATION *********************
    data :  gs_bsik type tt_bsik,
            gs_bsak type tt_bsik,
            gs_lfb1 type tt_lfb1,
            gs_lfa1 type tt_lfa1,
            gs_ageing  type tt_ageing,
            gs_bs type tt_bs,
            gs_opdisp type tt_bs,
            gs_final type tt_bsik,
            gs_opbal type tt_opbal,
            gs_opfinal type tt_opbal.
    ************INTERNAL TABLE DECLARATION*************
    data :  gt_bsik type standard table of tt_bsik,
            gt_bsak type standard table of tt_bsik,
            gt_lfb1 type standard table of tt_lfb1,
            gt_lfa1 type standard table of tt_lfa1,
            gt_ageing type standard table of tt_ageing,
            gt_bs type standard table of tt_bs,
            gt_opdisp type standard table of tt_bs,
            gt_final type standard table of tt_bsik,
            gt_opbal type standard table of tt_opbal,
            gt_opfinal type standard table of tt_opbal.
    ALV DECLARATIONS *******************
    data : gs_fcat type slis_fieldcat_alv ,
           gt_fcat type slis_t_fieldcat_alv ,
           gs_sort type slis_sortinfo_alv,
           gs_fcats type slis_fieldcat_alv ,
           gt_fcats type slis_t_fieldcat_alv.
    **********global data declration***************
    data :   kb type dmbtr ,
              return like  bapireturn ,
              balancespgli like  bapi3008-bal_sglind,
              noteditems like  bapi3008-ntditms_rq,
              keybalance type table of  bapi3008_3 with header line,
             opbalance type p.
    SELECTION SCREEN DECLARATIONS *********************
    selection-screen begin of block b1 with frame .
    select-options : so_bukrs for bsik-bukrs obligatory,
                     so_lifnr for bsik-lifnr,
                     so_hkont for bsik-hkont,
                     so_prctr for bsik-prctr ,
                     so_mindk for lfb1-mindk,
                     so_ktokk for lfa1-ktokk.
    selection-screen end of block b1.
    selection-screen : begin of block b1 with frame.
    parameters       : p_rb1 radiobutton group rad1 .
    select-options   : so_date for sy-datum .
    selection-screen : end of block b1.
    ********************************ASSIGNING ALV GRID
    ****field catalog for balance report
    gs_fcats-col_pos = 1.
    gs_fcats-fieldname = 'BUKRS'.
    gs_fcats-seltext_m =  text-001.
    append gs_fcats to gt_fcats .
    gs_fcats-col_pos = 2 .
    gs_fcats-fieldname = 'LIFNR'.
    gs_fcats-seltext_m = text-002.
    append gs_fcats to gt_fcats .
    gs_fcats-col_pos = 3.
    gs_fcats-fieldname = 'NAME1'.
    gs_fcats-seltext_m =  text-003.
    append gs_fcats to gt_fcats .
    gs_fcats-col_pos = 4.
    gs_fcats-fieldname = 'BALC'.
    gs_fcats-seltext_m =  text-016.
    append gs_fcats to gt_fcats .
    gs_fcats-col_pos = 5.
    gs_fcats-fieldname = 'BALA'.
    gs_fcats-seltext_m =  text-012.
    append gs_fcats to gt_fcats .
    gs_fcats-col_pos = 6.
    gs_fcats-fieldname = 'BALB'.
    gs_fcats-seltext_m =  text-013.
    append gs_fcats to gt_fcats .
    gs_fcats-col_pos = 7.
    gs_fcats-fieldname = 'TBAL'.
    gs_fcats-seltext_m =  text-014.
    append gs_fcats to gt_fcats .
    gs_fcats-col_pos = 8.
    gs_fcats-fieldname = 'GBAL'.
    gs_fcats-seltext_m =  text-015.
    append gs_fcats to gt_fcats .
    data : repid1 type sy-repid.
    repid1 = sy-repid.
    INITIALIZATION EVENTS ******************************
    initialization.
    *Clearing the work area.
    clear gs_bsik.
    Refreshing the internal tables.
    refresh gt_bsik.
    ******************START OF  SELECTION EVENTS **************************
    start-of-selection.
    *get data for balance report.
      perform sub_openbal.
      perform sub_openbal_display.
    *&      Form  sub_openbal
          text
    -->  p1        text
    <--  p2        text
    form sub_openbal .
      if   so_date-low > sy-datum or so_date-high > sy-datum .
          message i005(yfi02).
         leave screen.
    endif.
         select bukrs lifnr gjahr belnr budat bldat
           waers dmbtr wrbtr shkzg blart monat hkont prctr
           from bsik into table gt_opbal
           where bukrs in so_bukrs and lifnr in so_lifnr
           and hkont in so_hkont and prctr in so_prctr
           and budat in so_date .
        select bukrs lifnr gjahr belnr budat bldat
           waers dmbtr wrbtr shkzg blart monat hkont prctr
           from bsak appending table gt_opbal
           for all entries in gt_opbal
           where lifnr = gt_opbal-lifnr
           and budat in so_date .
    if sy-subrc <> 0.
      message i007(yfi02).
      leave screen.
      endif.
    select lifnr mindk from lfb1 into table gt_lfb1
      for all entries in gt_opbal
        where lifnr = gt_opbal-lifnr and mindk in so_mindk.
    select lifnr name1 ktokk from lfa1 into table gt_lfa1
      for all entries in gt_opbal
       where lifnr = gt_opbal-lifnr and ktokk in so_ktokk.
       loop at gt_opbal into gs_opbal .
         loop at gt_lfb1 into gs_lfb1 where lifnr = gs_opbal-lifnr.
           loop at gt_lfa1 into gs_lfa1 where lifnr = gs_opbal-lifnr.
            gs_opfinal-bukrs = gs_opbal-bukrs.
            gs_opfinal-lifnr = gs_opbal-lifnr.
            gs_opfinal-gjahr = gs_opbal-gjahr.
            gs_opfinal-belnr = gs_opbal-belnr.
            gs_opfinal-budat = gs_opbal-budat.
            gs_opfinal-bldat = gs_opbal-bldat.
            gs_opfinal-waers = gs_opbal-waers.
            gs_opfinal-dmbtr = gs_opbal-dmbtr.
            gs_opfinal-wrbtr = gs_opbal-wrbtr.
            gs_opfinal-shkzg = gs_opbal-shkzg.
            gs_opfinal-blart = gs_opbal-blart.
            gs_opfinal-monat = gs_opbal-monat.
            gs_opfinal-hkont = gs_opbal-hkont.
            gs_opfinal-prctr = gs_opbal-prctr.
            gs_opfinal-name1 = gs_lfa1-name1.
        if gs_opbal-shkzg    = 'H'.
            gs_opfinal-tcr   =  gs_opbal-dmbtr * -1.
            gs_opfinal-tdr   =  '000000'.
        else.
            gs_opfinal-tdr   =  gs_opbal-dmbtr.
            gs_opfinal-tcr   =  '000000'.
        endif.
           append gs_opfinal to gt_opfinal.
           endloop.
           endloop.
           endloop.
    sort gt_opfinal by bukrs lifnr prctr .
    so_date-low = so_date-low - 1 .
    loop at gt_opfinal into gs_opfinal.
    call function 'BAPI_AP_ACC_GETKEYDATEBALANCE'
      exporting
        companycode        = gs_opfinal-bukrs
        vendor             =  gs_opfinal-lifnr
        keydate            = so_date-low
       balancespgli        = ' '
       noteditems          = ' '
      importing
        return             = return
      tables
        keybalance         = keybalance.
    clear kb .
    loop at keybalance .
       kb = keybalance-lc_bal + kb .
    endloop.
          gs_opdisp-balc = kb.
          gs_opdisp-bukrs =  gs_opfinal-bukrs.
          gs_opdisp-lifnr =  gs_opfinal-lifnr.
          gs_opdisp-name1 =  gs_opfinal-name1.
        at new lifnr .
          sum .
          gs_opfinal-tbal =  gs_opfinal-tdr + gs_opfinal-tcr  .
          gs_opdisp-tbal = gs_opfinal-tbal.
          gs_opdisp-bala = gs_opfinal-tdr .
          gs_opdisp-balb = gs_opfinal-tcr .
          gs_opdisp-gbal = keybalance-lc_bal + gs_opfinal-tbal .
          append gs_opdisp to gt_opdisp.
        endat.
        clear gs_opdisp.
        clear keybalance .
      endloop.
      delete adjacent duplicates from gt_opdisp.
    endform.                    " sub_openbal
    *&      Form  sub_openbal_display
          text
    -->  p1        text
    <--  p2        text
    form sub_openbal_display .
    call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
          i_callback_program              =  repid1
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
          it_fieldcat                     = gt_fcats
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = 'X'
      IS_VARIANT                        =
       it_events                        =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
         tables
           t_outtab                       = gt_opdisp
      exceptions
        program_error                     = 1
        others                            = 2
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " sub_openbal_display

    I think you are using for all entries statement in almost all select statements but i didnt see any condtion before you are using for all entries statement.
    If you are using for all entries in gt_opbal ... make sure that gt_opbal has some records other wise it will try to read all records from the data base tables.
    Try to check before using for all entries in the select statement like
    if gt_opbal is not initial.
    select adfda adfadf afdadf into table
      for all entries in gt_opbal.
    else.
    select abdf afad into table
    from abcd
    where a = 1
        and b = 2.
    endif.
    i didnt see anything wrong in your report but this is major time consuming when you dont have records in the table which you are using for all entries.

  • Regarding performance enhancement to reduce execution time

    Hi ,
    actually there is a following piece of code(a SELECT query) in my program,due to which TIME OUT dump occurs.plz help me to modify the code to reduce it's execution time.
    code is:
    DATA: at_seque_extref TYPE zprms_ord_ind OCCURS 0 WITH HEADER LINE.
                SELECT (sv_fields) FROM zprms_ord_ind
                  APPENDING CORRESPONDING FIELDS OF TABLE at_seque
                     UP TO lv_max_sequs ROWS
                      WHERE process_type    IN lr_process_type
                        AND   posting_date    IN lr_pos_date
                        AND   sol_date        IN lr_sol_date
                        AND   changed_at      IN lr_chg_date
                      AND   external_ref    NE space
                        AND  (ls_where)
                        AND   ib_comp_network IN lr_ibc_netw
                        AND   ib_comp_node    IN lr_ibc_node
                        AND   ib_comp_site    IN lr_ibc_site
                    ORDER BY (iv_order_by).
                CLEAR at_seque_extref.
                LOOP AT at_seque.
                  IF at_seque-external_ref CP is_bus_trans_search-external_ref  .
                    MOVE-CORRESPONDING  at_seque TO at_seque_extref.
                    APPEND at_seque_extref.
                  ENDIF.
                ENDLOOP.
                CLEAR at_seque[].
    *the table at_seque[]  type zprms_ord_ind
    Or plz suggest me check points to reduce it's execution time.

    DATA: at_seque_extref TYPE zprms_ord_ind OCCURS 0 WITH HEADER LINE.
    SELECT (sv_fields) FROM zprms_ord_ind
    <b>PACKAGE SIZE 100</b>
    APPENDING CORRESPONDING FIELDS OF TABLE at_seque
    UP TO lv_max_sequs ROWS
    WHERE process_type IN lr_process_type
    AND posting_date IN lr_pos_date
    AND sol_date IN lr_sol_date
    AND changed_at IN lr_chg_date
    AND external_ref NE space
    AND (ls_where)
    AND ib_comp_network IN lr_ibc_netw
    AND ib_comp_node IN lr_ibc_node
    AND ib_comp_site IN lr_ibc_site
    ORDER BY (iv_order_by).
    <b>ENDSELECT.</b>
    CLEAR at_seque_extref.
    LOOP AT at_seque.
    IF at_seque-external_ref CP is_bus_trans_search-external_ref .
    MOVE-CORRESPONDING at_seque TO at_seque_extref.
    APPEND at_seque_extref.
    ENDIF.
    ENDLOOP.
    CLEAR at_seque[].
    Make the necessary modifications.
    Copy paste the code.
    Regards,
    Pavan

  • Reducing execution time?

    hi all,
    Am running a report. It is taking long time for execution. What steps should i do to reduce the execution time.
    thanks in advance,
    ashu.

    Hi,
    use primary / secondary index keys in the where clause of the select query
    DO NOT use a negative in the where clause - it negates the index.
    While reading internal tables use binary search.
    sort itab by <field1 field2>
    read table itab with key <field1 field2> binary search.
    before using for all entries check if the internal table has something .. else all records form DB will get selected.
    Regards,
    Guarav

  • Want to modify procedure to reduce execution time.

    Hi,
    I am using oracle 10g.I had written a procedure which returns me list of telephone nos selected based on selection criteria.My procedure is working but its taking time.I am using a query which returns me list of rows.The count of row is very much.so each time it execute the query in loop, and it takes time.I want to use cursor so that at one time it will be executed and those records will be checked instead of executing the query everytime....
    The query which is used is :
    select * from abc;
    Please take this in cursor if possible...i had used it in my procedure below in for loop....I will be thankful to you in this regard.
    The procedure is below:
    create or replace PROCEDURE "OM_GET_SELECTED_TEL" (
    ni_array IN ty_npa_id,
    reqquantity IN NUMBER,
    availableinvids OUT ty_tel_no
    AS
    begin
    declare
    available ty_tel_no:= ty_tel_no();
    output VARCHAR2 (400);
    k number(3):= 1;
    BEGIN
    DBMS_OUTPUT.put_line ('tnType IS G');
    FOR i IN 1 .. ni_array.COUNT
    LOOP
    FOR j IN
    (SELECT tel_no,
    CASE
    WHEN REGEXP_LIKE (tel_no, '(\d)\1\1\1$')
    THEN 'condition 1 fullfilled'
    WHEN REGEXP_LIKE (tel_no, '(\d)\1(\d)\2$')
    THEN 'condition 2 fullfilled'
    WHEN REGEXP_LIKE (tel_no,
    '\d(\d)\1\1$|(\d)\2\2\d$'
    THEN 'condition 3 fullfilled'
    ELSE 'condition 4 fullfilled'
    END condition
    FROM (select * from abc) order by condition)
    LOOP
    output := j.condition;
    available.extend();
    IF (output = 'condition 1 fullfilled')
    THEN
    available(k) := j.tel_no;
    k := k+1;
    --availableinvids (i) := j.tel_no;
    DBMS_OUTPUT.put_line ('selected nos which satisfy condition 1:' || j.tel_no);
    ELSIF (output = 'condition 2 fullfilled')
    THEN
    available(k) := j.tel_no;
    k := k+1;
    --availableinvids (i) := j.tel_no;
    DBMS_OUTPUT.put_line ('selected nos which satisfy condition 2:' || j.tel_no);
    ELSIF (output = 'condition 3 fullfilled')
    THEN
    available(k) := j.tel_no;
    k := k+1;
    --availableinvids (i) := j.tel_no;
    DBMS_OUTPUT.put_line ('selected nos which satisfy condition 3:' || j.tel_no);
    ELSE
    available(k) := j.tel_no;
    k := k+1;
    DBMS_OUTPUT.put_line ('selected nos which dont satisfy condition :' || j.tel_no);
    END IF;
    EXIT WHEN k = reqquantity + 1 ;
    END LOOP;
    EXIT WHEN k = reqquantity + 1 ;
    END LOOP;
    end;
    END;

    kordirko thanks for your reply...but i didnt got your point.I need a stored procedure not a function also i had two cases and my query (select * from abc ) is a big query i had just written a sample query...it returns me a lot of tel nos. based on conditions in query....I am writing my complete procedure below.Please if possible give a alternate solution to reduce the time of query...if u want u may use cursor also...a function is also ok, if it returns what my procedure returns.U may see the query in both cases are same. So better take the query out of it....so that it may execute 1 time only, not mulitple times....Also ni_array is array which is passed to procedure.reqquantity is number of tel nos wanted in output...tntype is either S or G....and availableinvids gives me the ouput.....I will be thankful to you in this regard.
    My full procedure is below:
    create or replace PROCEDURE "OM_GET_SELECTED_TEL" (
    ni_array IN ty_npa_id,
    reqquantity IN NUMBER,
    tntype IN VARCHAR2,
    availableinvids OUT ty_tel_no
    AS
    begin
    declare
    available ty_tel_no:= ty_tel_no();
    output VARCHAR2 (400);
    k number(3):= 1;
    BEGIN
    IF tntype = 'G'
    THEN
    DBMS_OUTPUT.put_line ('tnType IS G');
    FOR i IN 1 .. ni_array.COUNT
    LOOP
    FOR j IN
    (SELECT tel_no,
    CASE
    WHEN REGEXP_LIKE (tel_no, '(\d)\1\1\1$')
    THEN 'condition 1 fullfilled'
    WHEN REGEXP_LIKE (tel_no, '(\d)\1(\d)\2$')
    THEN 'condition 2 fullfilled'
    WHEN REGEXP_LIKE (tel_no,
    '\d(\d)\1\1$|(\d)\2\2\d$'
    THEN 'condition 3 fullfilled'
    ELSE 'condition 4 fullfilled'
    END condition
    FROM (select * from abc) order by condition)
    LOOP
    output := j.condition;
    available.extend();
    IF (output = 'condition 1 fullfilled')
    THEN
    available(k) := j.tel_no;
    k := k+1;
    --availableinvids (i) := j.tel_no;
    DBMS_OUTPUT.put_line ('selected nos which satisfy condition 1:' || j.tel_no);
    ELSIF (output = 'condition 2 fullfilled')
    THEN
    available(k) := j.tel_no;
    k := k+1;
    --availableinvids (i) := j.tel_no;
    DBMS_OUTPUT.put_line ('selected nos which satisfy condition 2:' || j.tel_no);
    ELSIF (output = 'condition 3 fullfilled')
    THEN
    available(k) := j.tel_no;
    k := k+1;
    --availableinvids (i) := j.tel_no;
    DBMS_OUTPUT.put_line ('selected nos which satisfy condition 3:' || j.tel_no);
    ELSE
    available(k) := j.tel_no;
    k := k+1;
    DBMS_OUTPUT.put_line ('selected nos which dont satisfy condition :' || j.tel_no);
    END IF;
    EXIT WHEN k = reqquantity + 1 ;
    END LOOP;
    EXIT WHEN k = reqquantity + 1 ;
    END LOOP;
    ELSIF tntype = 'S'
    THEN
    DBMS_OUTPUT.put_line ('tnType IS S');
    FOR i IN 1 .. ni_array.COUNT
    LOOP
    FOR j IN
    WITH     got_grp_id AS
         SELECT     tel_no
         ,     REGEXP_REPLACE ( tel_no
                   , '-\d+$'
                   )     AS nos_part_1
         ,     TO_NUMBER ( REGEXP_SUBSTR ( tel_no
                             , '\d+$'
                   ) - ROW_NUMBER () OVER ( PARTITION BY REGEXP_REPLACE ( tel_no
                                                      , '-\d+$'
                                  ORDER BY     tel_no
                                  ) AS grp_id
         FROM (select * from abc
    ,     got_grp_cnt     AS
    SELECT     got_grp_id.*
    ,     COUNT (1) OVER ( PARTITION BY nos_part_1
    ,     grp_id
    ) AS grp_cnt
    FROM     got_grp_id
    ORDER BY grp_cnt     DESC
    ,      tel_no
    SELECT     tel_no
    FROM     got_grp_cnt
    WHERE     ROWNUM     <= reqquantity
    LOOP
    output := j.tel_no;
    DBMS_OUTPUT.put_line ('reqquantity:'||reqquantity) ;
    available.extend();
    available(k) := output;
    k := k+1;
    DBMS_OUTPUT.put_line ('selected nos for S type are:' || j.tel_no) ;
    END LOOP;
    END LOOP;
    ELSE
    DBMS_OUTPUT.put_line ('WRONG TNTYPE');
    END IF;
    end;
    END;

  • SQL Tuning and OPTIMIZER - Execution Time with  " AND col .."

    Hi all,
    I get a question about SQL Tuning and OPTIMIZER.
    There are three samples with EXPLAIN PLAN and execution time.
    This "tw_pkg.getMaxAktion" is a PLSQL Package.
    1.) Execution Time : 0.25 Second
    2.) Execution Time : 0.59 Second
    3.) Execution Time : 1.11 Second
    The only difference is some additional "AND col <> .."
    Why is this execution time growing so strong?
    Many Thanks,
    Thomas
    ----[First example]---
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Connected as dbadmin2
    SQL>
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM ( SELECT studie_id, tw_pkg.getMaxAktion(studie_id) AS max_aktion_id
      3                    FROM studie
      4                 ) max_aktion
      5  WHERE max_aktion.max_aktion_id < 900 ;
    Explained
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3201460684
    | Id  | Operation            | Name        | Rows  | Bytes | Cost (%CPU)| Time
    |   0 | SELECT STATEMENT     |             |   220 |   880 |     5  (40)| 00:00:
    |*  1 |  INDEX FAST FULL SCAN| SYS_C005393 |   220 |   880 |     5  (40)| 00:00:
    Predicate Information (identified by operation id):
       1 - filter("TW_PKG"."GETMAXAKTION"("STUDIE_ID")<900)
    13 rows selected
    SQL>
    Execution time (PL/SQL Developer says): 0.25 seconds
    ----[/First]---
    ----[Second example]---
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Connected as dbadmin2
    SQL>
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM ( SELECT studie_id, tw_pkg.getMaxAktion(studie_id) AS max_aktion_id
      3                    FROM studie
      4                 ) max_aktion
      5  WHERE max_aktion.max_aktion_id < 900
      6    AND max_aktion.max_aktion_id <> 692;
    Explained
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3201460684
    | Id  | Operation            | Name        | Rows  | Bytes | Cost (%CPU)| Time
    |   0 | SELECT STATEMENT     |             |    11 |    44 |     6  (50)| 00:00:
    |*  1 |  INDEX FAST FULL SCAN| SYS_C005393 |    11 |    44 |     6  (50)| 00:00:
    Predicate Information (identified by operation id):
       1 - filter("TW_PKG"."GETMAXAKTION"("STUDIE_ID")<900 AND
                  "TW_PKG"."GETMAXAKTION"("STUDIE_ID")<>692)
    14 rows selected
    SQL>
    Execution time (PL/SQL Developer says): 0.59 seconds
    ----[/Second]---
    ----[Third example]---
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM ( SELECT studie_id, tw_pkg.getMaxAktion(studie_id) AS max_aktion_id
      3                    FROM studie
      4                 ) max_aktion
      5  WHERE max_aktion.max_aktion_id < 900
      6    AND max_aktion.max_aktion_id <> 692
      7    AND max_aktion.max_aktion_id <> 392;
    Explained
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3201460684
    | Id  | Operation            | Name        | Rows  | Bytes | Cost (%CPU)| Time
    |   0 | SELECT STATEMENT     |             |     1 |     4 |     6  (50)| 00:00:
    |*  1 |  INDEX FAST FULL SCAN| SYS_C005393 |     1 |     4 |     6  (50)| 00:00:
    Predicate Information (identified by operation id):
       1 - filter("TW_PKG"."GETMAXAKTION"("STUDIE_ID")<900 AND
                  "TW_PKG"."GETMAXAKTION"("STUDIE_ID")<>692 AND
                  "TW_PKG"."GETMAXAKTION"("STUDIE_ID")<>392)
    15 rows selected
    SQL>
    Execution time (PL/SQL Developer says): 1.11 seconds
    ----[/Third]---Edited by: thomas_w on Jul 9, 2010 11:35 AM
    Edited by: thomas_w on Jul 12, 2010 8:29 AM

    Hi,
    this is likely because SQL Developer fetches and displays only limited number of rows from query results.
    This number is a parameter called 'sql array fetch size', you can find it in SQL Developer preferences under Tools/Preferences/Database/Advanced tab, and it's default value is 50 rows.
    Query scans a table from the beginning and continue scanning until first 50 rows are selected.
    If query conditions are more selective, then more table rows (or index entries) must be scanned to fetch first 50 results and execution time grows.
    This effect is usually unnoticeable when query uses simple and fast built-in comparison operators (like = <> etc) or oracle built-in functions, but your query uses a PL/SQL function that is much more slower than built-in functions/operators.
    Try to change this parameter to 1000 and most likely you will see that execution time of all 3 queries will be similar.
    Look at this simple test to figure out how it works:
    CREATE TABLE studie AS
    SELECT row_number() OVER (ORDER BY object_id) studie_id,  o.*
    FROM (
      SELECT * FROM all_objects
      CROSS JOIN
      (SELECT 1 FROM dual CONNECT BY LEVEL <= 100)
    ) o;
    CREATE INDEX studie_ix ON studie(object_name, studie_id);
    ANALYZE TABLE studie COMPUTE STATISTICS;
    CREATE OR REPLACE FUNCTION very_slow_function(action IN NUMBER)
    RETURN NUMBER
    IS
    BEGIN
      RETURN action;
    END;
    /'SQL array fetch size' parameter in SQLDeveloper has been set to 50 (default). We will run 3 different queries on test table.
    Query 1:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id < 900
    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        1      1.22       1.29          0       1310          0          50
    total        3      1.22       1.29          0       1310          0          50
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
         50  INDEX FAST FULL SCAN STUDIE_IX (cr=1310 pr=0 pw=0 time=355838 us cost=5536 size=827075 card=165415)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
         50   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 2:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id < 900
          AND max_aktion.max_aktion_id > 800
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.01          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      8.40       8.62          0       9351          0          50
    total        3      8.40       8.64          0       9351          0          50
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
         50  INDEX FAST FULL SCAN STUDIE_IX (cr=9351 pr=0 pw=0 time=16988202 us cost=5552 size=41355 card=8271)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
         50   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 3:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id = 600
    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        1     18.72      19.16          0      19315          0           1
    total        3     18.73      19.16          0      19315          0           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
          1  INDEX FAST FULL SCAN STUDIE_IX (cr=19315 pr=0 pw=0 time=0 us cost=5536 size=165415 card=33083)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          1   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 1 - 1,29 sec, 50 rows fetched, 1310 index entries scanned to find these 50 rows.
    Query 2 - 8,64 sec, 50 rows fetched, 9351 index entries scanned to find these 50 rows.
    Query 3 - 19,16 sec, only 1 row fetched, 19315 index entries scanned (full index).
    Now 'SQL array fetch size' parameter in SQLDeveloper has been set to 1000.
    Query 1:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id < 900
    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        1     18.35      18.46          0      19315          0         899
    total        3     18.35      18.46          0      19315          0         899
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
        899  INDEX FAST FULL SCAN STUDIE_IX (cr=19315 pr=0 pw=0 time=20571272 us cost=5536 size=827075 card=165415)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
        899   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 2:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id < 900
          AND max_aktion.max_aktion_id > 800
    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        1     18.79      18.86          0      19315          0          99
    total        3     18.79      18.86          0      19315          0          99
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
         99  INDEX FAST FULL SCAN STUDIE_IX (cr=19315 pr=0 pw=0 time=32805696 us cost=5552 size=41355 card=8271)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
         99   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)Query 3:
    SELECT * FROM ( SELECT studie_id, very_slow_function(studie_id) AS max_aktion_id
                         FROM studie
                  ) max_aktion
    WHERE max_aktion.max_aktion_id = 600
    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        1     18.69      18.84          0      19315          0           1
    total        3     18.69      18.84          0      19315          0           1
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 93  (TEST)
    Rows     Row Source Operation
          1  INDEX FAST FULL SCAN STUDIE_IX (cr=19315 pr=0 pw=0 time=0 us cost=5536 size=165415 card=33083)(object id 79865)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          1   INDEX   MODE: ANALYZED (FAST FULL SCAN) OF 'STUDIE_IX' (INDEX)And now:
    Query 1 - 18.46 sec, 899 rows fetched, 19315 index entries scanned.
    Query 2 - 18.86 sec, 99 rows fetched, 19315 index entries scanned.
    Query 3 - 18.84 sec, 1 row fetched, 19315 index entries scanned.

  • How to reduce execution time of this SQL?

    This SQL will output only 2 rows. I tried using hints (an index) but to no avail.
    http://www.freeimagehosting.net/uploads/cf214afcf1.jpg
    Or, is it NOT possible, limit of query optimization has reached?

    Rakesh jayappa wrote:
    Hi,
    Run the sql tuning advisory.
    Let me know recommendation.
    Kind Regards,
    Rakesh************************** Here is my tuning request **************************
    1.) The following SQL statement has been identified to perform poorly. It currently takes up to 12 seconds to execute, but it's supposed to take a second at most.
    This is the statement:
    select DISTINCT trunc(c.sst_post_date) as post_date
    from ac_t_sessn b , ac_t_ssntr c
    where
           b.ses_status = 0
              and b.ses_profit_center = c.sst_profit_center
              and b.ses_acct_year = c.sst_acct_year
              and b.ses_acct_period = c.sst_acct_period
              and b.ses_sessn_no = c.sst_sessn_no
       AND
             C.sst_post_mtd||C.sst_post_TYPE IN
           (SELECT Y.pst_post_mtd||Y.pst_post_type
            FROM ac_r_post_functions Y
           WHERE Y.pst_post_status IN (0,'2'))
    order by trunc(c.sst_post_date);It should return data from a table in a specific order.
    2.) The version of the database is Oracle9i Enterprise Edition Release *9.2.0.6.0*
    3.) These are the parameters relevant to the optimizer:
    UAT_UML@umltest>show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_dynamic_sampling           integer     1
    optimizer_features_enable            string      9.2.0
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_max_permutations           integer     2000
    optimizer_mode                       string      CHOOSE
    UAT_UML@umltest>show parameter db_file_multi
    NAME                                 TYPE        VALUE
    db_file_multiblock_read_count        integer     16
    UAT_UML@umltest>show parameter db_block_size
    NAME                                 TYPE        VALUE
    db_block_size                        integer     8192
    UAT_UML@umltest>show parameter cursor_sharing
    NAME                                 TYPE        VALUE
    cursor_sharing                       string      EXACT
    UAT_UML@umltest>column sname format a20
    UAT_UML@umltest>column pname format a20
    UAT_UML@umltest>column pval2 format a20
    UAT_UML@umltest>select
      2             sname
      3           , pname
      4           , pval1
      5           , pval2
      6      from
      7           sys.aux_stats$;
    no rows selected4.) Here is the output of EXPLAIN PLAN:
    UAT_UML@umltest>select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation              |  Name                | Rows  | Bytes |TempSpc| Cost  |
    |   0 | SELECT STATEMENT       |                      |   454 | 22700 |       |  5391 |
    |   1 |  SORT UNIQUE           |                      |   454 | 22700 |       |  5072 |
    |   2 |   HASH JOIN            |                      | 69384 |  3387K|  2592K|  4478 |
    |   3 |    INDEX FAST FULL SCAN| INDX_AC_T_SESSN      |   110K|  1294K|       |   244 |
    |   4 |    HASH JOIN           |                      |   416K|    15M|       |  3877 |
    |   5 |     TABLE ACCESS FULL  | AC_R_POST_FUNCTIONS  |    23 |   253 |       |     2 |
    |   6 |     TABLE ACCESS FULL  | AC_T_SSNTR           |  1790K|    46M|       |  3866 |
    Note: cpu costing is off, PLAN_TABLE' is old version5.) Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
    UAT_UML@umltest>set autotrace traceonly arraysize 100
    UAT_UML@umltest>
    UAT_UML@umltest>select DISTINCT trunc(c.sst_post_date) as post_date
      2  from ac_t_sessn b , ac_t_ssntr c
      3  where
      4  b.ses_status = 0
      5  and b.ses_profit_center = c.sst_profit_center
      6  and b.ses_acct_year = c.sst_acct_year
      7  and b.ses_acct_period = c.sst_acct_period
      8  and b.ses_sessn_no = c.sst_sessn_no
      9  AND
    10  C.sst_post_mtd||C.sst_post_TYPE IN (SELECT         Y.pst_post_mtd||Y.pst_post_type FROM ac_r_po
    st_functions Y
    11  WHERE Y.pst_post_status IN (0,'2'))
    12  order by trunc(c.sst_post_date);
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=5391 Card=454 Bytes=
              22700)
       1    0   SORT (UNIQUE) (Cost=5072 Card=454 Bytes=22700)
       2    1     HASH JOIN (Cost=4478 Card=69384 Bytes=3469200)
       3    2       INDEX (FAST FULL SCAN) OF 'INDX_AC_T_SESSN' (NON-UNIQU
              E) (Cost=244 Card=110433 Bytes=1325196)
       4    2       HASH JOIN (Cost=3877 Card=416304 Bytes=15819552)
       5    4         TABLE ACCESS (FULL) OF 'AC_R_POST_FUNCTIONS' (Cost=2
               Card=23 Bytes=253)
       6    4         TABLE ACCESS (FULL) OF 'AC_T_SSNTR' (Cost=3866 Card=
              1790555 Bytes=48344985)
    Statistics
              0  recursive calls
              0  db block gets
          42741  consistent gets
            171  physical reads
              0  redo size
            425  bytes sent via SQL*Net to client
            507  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
              2  rows processed
    UAT_UML@umltest>DISCONNECT
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production6.) The TKPROF output snippet
    TKPROF: Release 11.2.0.1.0 - Development on Wed Oct 27 12:47:35 2010
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Trace file: umltest_ora_1604.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 DISTINCT trunc(c.sst_post_date) as post_date
    from ac_t_sessn b , ac_t_ssntr c
    where
    b.ses_status = 0
    and b.ses_profit_center = c.sst_profit_center
    and b.ses_acct_year = c.sst_acct_year
    and b.ses_acct_period = c.sst_acct_period
    and b.ses_sessn_no = c.sst_sessn_no
    AND
    C.sst_post_mtd||C.sst_post_TYPE IN (SELECT         Y.pst_post_mtd||Y.pst_post_type FROM ac_r_post_functions Y
    WHERE Y.pst_post_status IN (0,'2'))
    order by trunc(c.sst_post_date)
    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      3.20       4.38        171      42741          0           2
    total        4      3.21       4.39        171      42741          0           2
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: 445 
    Rows     Row Source Operation
          2  SORT UNIQUE
         24   HASH JOIN 
         11    INDEX FAST FULL SCAN OBJ#(62817) (object id 62817)
    2293715    HASH JOIN 
         31     TABLE ACCESS FULL OBJ#(67305)
    1790555     TABLE ACCESS FULL OBJ#(62828)
    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.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        1      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: 445 
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      2      0.00       0.00          0          0          0           0
    Fetch        2      3.20       4.38        171      42741          0           2
    total        5      3.21       4.39        171      42741          0           2
    Misses in library cache during parse: 1
    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: umltest_ora_1604.trc
    Trace file compatibility: 9.02.00
    Sort options: prsela  exeela  fchela 
           1  session 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.
          51  lines in trace file.
          10  elapsed seconds in trace file. Any help would be greatly appreciated?

  • Query Database: reduce execution time

    Hi to all,
    I have Oracle 11g R2.
    I want reduce to max the execution time of this my select:
    SELECT a.ID, a.FULLNAME, a.L_AXON, a.R_AXON, a.L_LAXON, a.R_LAXON, a.L_F_F_ADD, a.R_F_F_ADD, a.L_T_F_ADD, a.R_T_F_ADD, a.L_PC, a.R_PC FROM ITALIA_GC a WHERE SDO_WITHIN_DISTANCE(a.GEOMETRY, MDSYS.SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(13.8268523, 41.491619, NULL) ,NULL, NULL), 'DISTANCE=100 UNIT=M') = 'TRUE' AND ROWNUM=1;
    This query returns the name, city, postal code and address of a street of Italy. These datas are in ITALIA_GC table.
    I already created an spatial index on GEOMETRY field of this table:
    CREATE INDEX ITALIA_GC_IDX ON ITALIA_GC(GEOMETRY) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    How can I see the execution time (i need to know the execution time in milliseconds) of this query and how can I reduce to max it?
    thank you very much in advance.
    Crystal

    Thank you.
    I used explain plan and SQL*Trace/tkprof method.
    What I would like to know is if the execution time are misured in seconds or milliseconds (I wish to know misure in millisecond).
    The result of SQL*Trace/tkprof method is:
    TKPROF: Release 11.2.0.1.0 - Development on Tue Jul 27 15:33:28 2010
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Trace file: dbuir_ora_29053.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
    SQL ID: 1bf1x0q79c1rm
    Plan Hash: 2374671442
    SELECT a.ID, a.FULLNAME, a.L_AXON, a.R_AXON, a.L_LAXON, a.R_LAXON,
      a.L_F_F_ADD, a.R_F_F_ADD, a.L_T_F_ADD, a.R_T_F_ADD, a.L_PC, a.R_PC
    FROM
    ITALIA_GC a WHERE SDO_WITHIN_DISTANCE(a.GEOMETRY, MDSYS.SDO_GEOMETRY(2001,
      8307, MDSYS.SDO_POINT_TYPE(13.8268523, 41.491619, NULL) ,NULL, NULL),
      'DISTANCE=100 UNIT=M') = '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.00       0.02          0         30          2           0
    Fetch        2      0.00       0.00          0         14          0           1
    total        4      0.00       0.02          0         44          2           1
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 85 
    Rows     Row Source Operation
          1  COUNT STOPKEY (cr=110 pr=0 pw=0 time=0 us)
          1   TABLE ACCESS BY INDEX ROWID ITALIA_GC (cr=110 pr=0 pw=0 time=0 us cost=0 size=4142 card=1)
          1    DOMAIN INDEX  ITALIA_GC_IDX (cr=109 pr=0 pw=0 time=0 us cost=0 size=0 card=0)
    SQL ID: 20y2xs9zmrbc5
    Plan Hash: 4105568395
    SELECT a."GEOMETRY"
    FROM
    "SPATIAL".ITALIA_GC a where a.rowid=:rid
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute     20      0.00       0.00          0          0          0           0
    Fetch       20      0.00       0.00          0         20          0          20
    total       41      0.00       0.00          0         20          0          20
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 85     (recursive depth: 1)
    Rows     Row Source Operation
          1  TABLE ACCESS BY USER ROWID ITALIA_GC (cr=1 pr=0 pw=0 time=0 us cost=1 size=3831 card=1)
    SQL ID: 9pxc8jgf3tj20
    Plan Hash: 1946957531
    SELECT diminfo, nvl(srid,-1)
    FROM
      ALL_SDO_GEOM_METADATA WHERE OWNER = :own AND TABLE_NAME = NLS_UPPER(:tab)
      AND '"'||COLUMN_NAME||'"' = :col
    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        1      0.00       0.00          0          9          0           1
    total        3      0.00       0.00          0          9          0           1
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 85     (recursive depth: 1)
    Rows     Row Source Operation
          1  VIEW  ALL_SDO_GEOM_METADATA (cr=9 pr=0 pw=0 time=0 us cost=25 size=654 card=2)
          1   UNION-ALL  (cr=9 pr=0 pw=0 time=0 us)
          1    MERGE JOIN CARTESIAN (cr=9 pr=0 pw=0 time=0 us cost=6 size=81 card=1)
          1     VIEW  ALL_OBJECTS (cr=7 pr=0 pw=0 time=0 us cost=5 size=45 card=1)
          1      FILTER  (cr=7 pr=0 pw=0 time=0 us)
          1       FILTER  (cr=7 pr=0 pw=0 time=0 us)
          1        NESTED LOOPS  (cr=7 pr=0 pw=0 time=0 us cost=5 size=124 card=1)
          1         NESTED LOOPS  (cr=6 pr=0 pw=0 time=0 us cost=4 size=102 card=1)
          1          TABLE ACCESS BY INDEX ROWID USER$ (cr=2 pr=0 pw=0 time=0 us cost=1 size=18 card=1)
          1           INDEX UNIQUE SCAN I_USER1 (cr=1 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 46)
          1          TABLE ACCESS BY INDEX ROWID OBJ$ (cr=4 pr=0 pw=0 time=0 us cost=3 size=84 card=1)
          1           INDEX RANGE SCAN I_OBJ5 (cr=3 pr=0 pw=0 time=0 us cost=2 size=0 card=1)(object id 40)
          1         INDEX RANGE SCAN I_USER2 (cr=1 pr=0 pw=0 time=0 us cost=1 size=22 card=1)(object id 47)
          0       TABLE ACCESS BY INDEX ROWID IND$ (cr=0 pr=0 pw=0 time=0 us cost=2 size=8 card=1)
          0        INDEX UNIQUE SCAN I_IND1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 41)
          0       HASH JOIN  (cr=0 pr=0 pw=0 time=0 us cost=3 size=24 card=1)
          0        INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=11 card=1)(object id 62)
          0        FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=1300 card=100)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=2 size=48 card=2)
          0        INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=11 card=1)(object id 62)
          0        FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=2)
          0       HASH JOIN  (cr=0 pr=0 pw=0 time=0 us cost=3 size=24 card=1)
          0        INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=11 card=1)(object id 62)
          0        FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=1300 card=100)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us)
          0        NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=7 size=78 card=1)
          0         NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=5 size=68 card=1)
          0          NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=4 size=57 card=1)
          0           MERGE JOIN CARTESIAN (cr=0 pr=0 pw=0 time=0 us cost=3 size=53 card=1)
          0            INDEX RANGE SCAN I_OBJ5 (cr=0 pr=0 pw=0 time=0 us cost=3 size=40 card=1)(object id 40)
          0            BUFFER SORT (cr=0 pr=0 pw=0 time=0 us cost=0 size=1300 card=100)
          0             FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=1300 card=100)
          0           INDEX RANGE SCAN I_USER2 (cr=0 pr=0 pw=0 time=0 us cost=1 size=4 card=1)(object id 47)
          0          INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=11 card=1)(object id 62)
          0         INDEX RANGE SCAN I_DEPENDENCY1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=0 card=3)(object id 106)
          0        TABLE ACCESS BY INDEX ROWID DEPENDENCY$ (cr=0 pr=0 pw=0 time=0 us cost=2 size=10 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=2 size=72 card=2)
          0        NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=2 size=23 card=1)
          0         TABLE ACCESS BY INDEX ROWID TRIGGER$ (cr=0 pr=0 pw=0 time=0 us cost=1 size=12 card=1)
          0          INDEX UNIQUE SCAN I_TRIGGER2 (cr=0 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 162)
          0         INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=11 card=1)(object id 62)
          0        FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=2)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us)
          0        NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=7 size=78 card=1)
          0         NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=5 size=68 card=1)
          0          NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=4 size=57 card=1)
          0           MERGE JOIN CARTESIAN (cr=0 pr=0 pw=0 time=0 us cost=3 size=53 card=1)
          0            INDEX RANGE SCAN I_OBJ5 (cr=0 pr=0 pw=0 time=0 us cost=3 size=40 card=1)(object id 40)
          0            BUFFER SORT (cr=0 pr=0 pw=0 time=0 us cost=0 size=1300 card=100)
          0             FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=1300 card=100)
          0           INDEX RANGE SCAN I_USER2 (cr=0 pr=0 pw=0 time=0 us cost=1 size=4 card=1)(object id 47)
          0          INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=11 card=1)(object id 62)
          0         INDEX RANGE SCAN I_DEPENDENCY1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=0 card=3)(object id 106)
          0        TABLE ACCESS BY INDEX ROWID DEPENDENCY$ (cr=0 pr=0 pw=0 time=0 us cost=2 size=10 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       VIEW  (cr=0 pr=0 pw=0 time=0 us cost=2 size=13 card=1)
          0        FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=2 size=21 card=1)
          0        INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=8 card=1)(object id 62)
          0        FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=13 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=2 size=21 card=1)
          0        INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=8 card=1)(object id 62)
          0        FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=13 card=1)
          0       FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
          0       VIEW  (cr=0 pr=0 pw=0 time=0 us cost=1 size=16 card=1)
          0        SORT GROUP BY (cr=0 pr=0 pw=0 time=0 us cost=1 size=86 card=1)
          0         NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=1 size=86 card=1)
          0          MERGE JOIN CARTESIAN (cr=0 pr=0 pw=0 time=0 us cost=0 size=78 card=1)
          0           NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=0 size=65 card=1)
          0            INDEX UNIQUE SCAN I_OLAP_CUBES$ (cr=0 pr=0 pw=0 time=0 us cost=0 size=13 card=1)(object id 940)
          0            TABLE ACCESS BY INDEX ROWID OLAP_DIMENSIONALITY$ (cr=0 pr=0 pw=0 time=0 us cost=0 size=52 card=1)
          0             INDEX RANGE SCAN I_OLAP_DIMENSIONALITY$ (cr=0 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 944)
          0           BUFFER SORT (cr=0 pr=0 pw=0 time=0 us cost=0 size=13 card=1)
          0            INDEX FULL SCAN I_OLAP_CUBE_DIMENSIONS$ (cr=0 pr=0 pw=0 time=0 us cost=0 size=13 card=1)(object id 928)
          0          INDEX RANGE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=8 card=1)(object id 36)
          0       NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=2 size=29 card=1)
          0        INDEX FULL SCAN I_USER2 (cr=0 pr=0 pw=0 time=0 us cost=1 size=20 card=1)(object id 47)
          0        INDEX RANGE SCAN I_OBJ4 (cr=0 pr=0 pw=0 time=0 us cost=1 size=9 card=1)(object id 39)
          1     BUFFER SORT (cr=2 pr=0 pw=0 time=0 us cost=6 size=36 card=1)
          1      TABLE ACCESS BY INDEX ROWID SDO_GEOM_METADATA_TABLE (cr=2 pr=0 pw=0 time=0 us cost=1 size=36 card=1)
          1       INDEX RANGE SCAN SDO_GEOM_IDX (cr=1 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 62259)
          0    FILTER  (cr=0 pr=0 pw=0 time=0 us)
          0     HASH JOIN  (cr=0 pr=0 pw=0 time=0 us cost=19 size=293 card=1)
          0      MERGE JOIN CARTESIAN (cr=0 pr=0 pw=0 time=0 us cost=18 size=238 card=1)
          0       NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us cost=18 size=225 card=1)
          0        NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us cost=17 size=221 card=1)
          0         NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us cost=16 size=213 card=1)
          0          NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us cost=15 size=209 card=1)
          0           NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us cost=14 size=201 card=1)
          0            NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us cost=13 size=196 card=1)
          0             NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=12 size=185 card=1)
          0              NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=11 size=181 card=1)
          0               NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=9 size=172 card=1)
          0                NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=8 size=144 card=1)
          0                 NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=7 size=123 card=1)
          0                  NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=6 size=120 card=1)
          0                   NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=5 size=90 card=1)
          0                    NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=2 size=54 card=1)
          0                     TABLE ACCESS BY INDEX ROWID USER$ (cr=0 pr=0 pw=0 time=0 us cost=1 size=18 card=1)
          0                      INDEX UNIQUE SCAN I_USER1 (cr=0 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 46)
          0                     TABLE ACCESS BY INDEX ROWID SDO_GEOM_METADATA_TABLE (cr=0 pr=0 pw=0 time=0 us cost=1 size=36 card=1)
          0                      INDEX RANGE SCAN SDO_GEOM_IDX (cr=0 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 62259)
          0                    TABLE ACCESS BY INDEX ROWID OBJ$ (cr=0 pr=0 pw=0 time=0 us cost=3 size=36 card=1)
          0                     INDEX RANGE SCAN I_OBJ2 (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)(object id 37)
          0                   TABLE ACCESS CLUSTER TAB$ (cr=0 pr=0 pw=0 time=0 us cost=1 size=30 card=1)
          0                    INDEX UNIQUE SCAN I_OBJ# (cr=0 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 3)
          0                  TABLE ACCESS CLUSTER TS$ (cr=0 pr=0 pw=0 time=0 us cost=1 size=3 card=1)
          0                   INDEX UNIQUE SCAN I_TS# (cr=0 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 7)
          0                 TABLE ACCESS CLUSTER COL$ (cr=0 pr=0 pw=0 time=0 us cost=1 size=21 card=1)
          0                TABLE ACCESS CLUSTER COLTYPE$ (cr=0 pr=0 pw=0 time=0 us cost=1 size=28 card=1)
          0               TABLE ACCESS BY INDEX ROWID OBJ$ (cr=0 pr=0 pw=0 time=0 us cost=2 size=9 card=1)
          0                INDEX RANGE SCAN I_OBJ3 (cr=0 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 38)
          0              INDEX RANGE SCAN I_USER2 (cr=0 pr=0 pw=0 time=0 us cost=1 size=4 card=1)(object id 47)
          0             TABLE ACCESS CLUSTER SEG$ (cr=0 pr=0 pw=0 time=0 us cost=1 size=11 card=1)
          0              INDEX UNIQUE SCAN I_FILE#_BLOCK# (cr=0 pr=0 pw=0 time=0 us cost=0 size=0 card=1)(object id 9)
          0            INDEX RANGE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=5 card=1)(object id 36)
          0           INDEX RANGE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=8 card=1)(object id 36)
          0          INDEX RANGE SCAN I_USER2 (cr=0 pr=0 pw=0 time=0 us cost=1 size=4 card=1)(object id 47)
          0         INDEX RANGE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=0 us cost=1 size=8 card=1)(object id 36)
          0        INDEX RANGE SCAN I_USER2 (cr=0 pr=0 pw=0 time=0 us cost=1 size=4 card=1)(object id 47)
          0       BUFFER SORT (cr=0 pr=0 pw=0 time=0 us cost=17 size=1300 card=100)
          0        FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=0 us cost=0 size=1300 card=100)
          0      FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=0 us cost=0 size=55 card=1)
          0     NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=2 size=21 card=1)
          0      INDEX RANGE SCAN I_OBJAUTH1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=8 card=1)(object id 62)
          0      FIXED TABLE FULL X$KZSRO (cr=0 pr=0 pw=0 time=0 us cost=0 size=13 card=1)
          0     FIXED TABLE FULL X$KZSPR (cr=0 pr=0 pw=0 time=0 us cost=0 size=26 card=1)
    ********************************************************************************The result of Explain plan method is:
    PLAN_TABLE_OUTPUT
    Plan hash value: 2374671442
    | Id  | Operation                    | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT             |               |     1 |  4142 |     0   (0)                | 00:00:01 |
    |*  1 |  COUNT STOPKEY               |               |       |       |         |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| ITALIA_GC     | 49989 |   197M|     0   (0)| 00:00:01 |
    |*  3 |    DOMAIN INDEX              | ITALIA_GC_IDX |       |       |     0   (0)               | 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM=1)
       3 - access("MDSYS"."SDO_WITHIN_DISTANCE"("A"."GEOMETRY","MDSYS"."SDO_GEOMETRY"(2001
    PLAN_TABLE_OUTPUT
                  ,8307,"MDSYS"."SDO_POINT_TYPE"(13.8268523,41.491619,NULL),NULL,NULL),'DISTANCE=100 UNIT=M')='TRUE')
    Note
       - dynamic sampling used for this statement (level=2)
    22 rows selected.thank you very much.

  • To reduce execution time of a Business Objects Dataservices job.

    The  issue that we are facing-
    Our goal-  To compare a record from a file  with 422928 records from another table on basis of  name & country, if a match is found then you take some specific columns of that matched record (from the table ) as our ouput.
    What we are doing-  We are at 1st  removing duplicates by doing matching on the address components (i.e.- addr_line1, city, state, postal code & country), here                    the break key for match transform is country & postal_code, its taking 1823.98 secs. Now the record count is 193317
                      Then we are merging the file record along with the 193317 records to put them in the same path and send them for matching.
                      The match criteria is the firm name & iso_country_cd,
                       the break key for match transform is the  iso_country_cd & the 1st  letter  of the name.
                       It took 1155.156 secs.
    We have used the "Run match as seperate process' option for the match to reduce the time.
    The whole job took  3038.805 secs.
    Please suggest how to reduce the execution time.
    Edited by: Susmit Das on Mar 29, 2010 7:41 AM

    This really is impossible to help with without seeing your code.
    Replacing while loops with Timed Loops will not help. Timed Loops are used for slowing while loops down in a controlled manner. You would use them to synchronise with a clock rate, and can set other parameters for priority and CPU allocation etc. These will not likely help to reduce your execution time.
    If you are seeing code execution of 1 second then you will need to optimise your code to reduce the execution time. There are LabVIEW guides on how to improve your code execution time, just search around for them.
    Also try using the Profiling tools to learn which VIs (I presume your code is componentised and each while loop contains subVIs?) are hogging the most CPU time.
    If you cannot share your VI then there it is very hard to know where your code execution bottlenecks are.
    Thoric (CLA, CLED, CTD and LabVIEW Champion)

  • Reduce execution time

    How to reduce the execution time of this code? 
    Loop at porder1.
    SELECT aufnr bstmg hsdat sgtxt bwart charg FROM mseg INTO
    (porder-aufnr,porder-bstmg,porder-hsdat,porder-sgtxt,porder-bwart,
    porder-charg)
                                             WHERE matnr = porder1-matnr AND
                                                   aufnr = porder1-aufnr AND
                                                   werks = porder1-pwerk AND
                                                   ( bwart = '101' OR
                                                     bwart = '102' ).
    Endselect.
    Endloop.
    Regards
    Praju .

    Hi prajwal.
    I would like to suggest,
    It is possible to reduce the time of execution by Increasing the number of fields in the WHERE clause as only those specific number of records are fetched which results in comparatively less execution time.
    Also, SAP has designed such powerfull tools like Transactions - ST05,  ST07, ST30, and many more
    I would like to suggest you a couple of references relating to your case,
    [SDN - Reference for Long execution time during processing of a select query|/thread/477540 [original link is broken];
    [SDN - Reference for Reducing the Execution time of the program - Tools|How can i reduce time of execution;
    [SDN - Reference for solutions to reduce the execution time of a program|How to reduce my query execution time?;
    Hope that's usefull.
    Good Luck & Regards.
    Harsh Dave

  • Reducing the time for select query

    Hi
    Please advise why the query is taking too much time to execute when the cost involved in the joins is less.
    Here is the explain plan for the same
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 4989 | 984K| | 295K (1)| 00:59:09 |
    | 1 | SORT ORDER BY | | 4989 | 984K| 2120K| 295K (1)| 00:59:09 |
    |* 2 | FILTER | | | | | | |
    |* 3 | HASH JOIN | | 4989 | 984K| | 12975 (1)| 00:02:36 |
    |* 4 | HASH JOIN | | 4989 | 862K| | 11943 (1)| 00:02:24 |
    | 5 | TABLE ACCESS FULL | tedy_hf | 993 | 22839 | | 17 (0)| 00:00:01 |
    |* 6 | HASH JOIN | | 4989 | 750K| | 11925 (1)| 00:02:24 |
    |* 7 | TABLE ACCESS FULL | tedy_hf453 | 145 | 2465 | | 7 (0)| 00:00:01 |
    |* 8 | HASH JOIN | | 4989 | 667K| | 11917 (1)| 00:02:24 |
    |* 9 | INDEX SKIP SCAN | tedy_ehf33 | 4987 | 116K| | 4992 (1)| 00:01:00 |
    |* 10 | TABLE ACCESS FULL| tedy_7nl | 43367 | 4785K| | 6925 (1)| 00:01:24 |
    | 11 | TABLE ACCESS FULL | tedy_hfeei | 89616 | 2187K| | 1032 (1)| 00:00:13 |
    |* 12 | TABLE ACCESS FULL | tedy_hf455 | 2 | 32 | | 113 (0)| 00:00:02 |
    --------------------------------------------------------------------------------------------------

    Because the cost is internally calculated by the Cost Based Optimizer using the data available when parsing the query (tables, columns, constraints, cardinalities, etc...). If you feed it bad information (stale statistics, not using NOT NULL constraints, check constraints, foreign key constraints, etc..) it chooses inappropriate access methods.
    Based on what you've posted, not much help is possible.
    When your query takes too long ...
    and
    HOW TO: Post a SQL statement tuning request - template posting
    Will get you started on providing meaningful information with which we can help you.

  • How to know child procedure Execution time with in parent procedure

    Hi Team,
    I've a requirement in which I need to get the execution time of a child procedure while its running in a parent procedure in PLSQL. While the child process is running, I want to know its execution time so that if it execution time exceeds more than 5 seconds than I want to through an error. Please let me know by what means this can be achieved in plsql.
    Regards,
    Tech D.

    TechD wrote:
    Hi Team,
    I've a requirement in which I need to get the execution time of a child procedure while its running in a parent procedure in PLSQL. While the child process is running, I want to know its execution time so that if it execution time exceeds more than 5 seconds than I want to through an error. Please let me know by what means this can be achieved in plsql.
    Regards,
    Tech D.PL/SQL is NOT a Real Time programming language.
    The procedure that invokes the child procedure is effectively dormant while the child runs.
    Plus there is no easy way to know when 5 seconds has elapsed.

  • Execution Time with Forge

    Is there any Performance improvements that can be applied to improve the run time with Forge? It takes us 90 minutes to complete.

    Hi Harley,
    The short answer is "it depends". There's a few quick hit things you can watch out for:
    unnecessary properties,
    work done in Forge that could be pushed to a database,
    Then there's more involved efforts that may or may not apply to your case, such as moving to parallel forge or removing Java manipulators.
    Dgidx has a few other things you can tune but it's mostly dependent on the character of your index and whether or not you are enabling unnecessary features on your properties and dimensions.
    Hope that helps, let us know if there's anything else you need.
    Patrick Rafferty
    http://branchbird.com

  • How Can I reduce Query Execution time with use of filter

    Dear Experts,
    In a query execution is faster when there is no product filter and these products can be a list contaning mare than 300 items.
    I am using In operator for that filter.

    Maybe if you posted the quer[y][ies] we could get a better idea.

  • Performance Tuning -To find the execution time for Select Statement

    Hi,
    There is a program that takes 10 hrs to execute. I need tune its performance. The program is basically reading few tables like KNA1,ANLA,ANLU,ADRC etc and updates to Custom table. I did my analysis and found few performance techniques for ABAP coding.
    Now my problem is, to get this object approved I need to submit the execution statistics to client.I checked both ST05 and SE30. I heard of a Tcode where we can execute a select statement and note its time, then modify and find its improved Performance. Can anybody suggest me on this.
    Thanks,
    Rajani.

    Hi,
    This is documentation regarding performance analysis. Hope this will be useful
    It is a general practice to use           Select  *  from <database>…     This statement populates all the values of the structure in the database.
    The effect is many fold:-
    •     It increases the time to retrieve data from database
    •     There is large amount of unused data in memory
    •     It increases the processing time from work area or internal tables
    It is always a good practice to retrieve only the required fields. Always use the syntax      Select f1  f2  …  fn  from <database>…      
    e.g.     Do not use the following statement:-
         Data: i_mara like mara occurs 0 with header line.
         Data: i_marc like marc occurs 0 with header line.
         Select * from mara
              Into table i_mara
              Where matnr in s_matnr.
         Select * from marc
              Into table i_marc
              For all entries in i_mara
              Where matnr eq i_mara-matnr.
         Instead use the following statement:-
                                       Data: begin of i_mara occurs 0,
                                            Matnr like mara-matnr,
                                                  End of i_mara.
         Data: begin of i_marc occurs 0,
              Matnr like marc-matnr,
                                            Werks like marc-werks,
                                                 End of i_marc.
         Select matnr from mara
              Into table i_mara
              Where matnr in s_matnr.

Maybe you are looking for

  • How to consume web service in Agentry in SMP 3.0

    Dear All , I am using web service in Agentry to retrive data but could not able to fetch it . I have made connection with HTTP-XML for consuming webservices. and also give proper information in Agentry.ini files Ex : [HTTPXML-2] name=HTTP-XML Back En

  • Cannot edit song infoPLEASE HELP!!!!!!!!!!!

    when i installed itunes i must of clicked to keep my itunes organized. i uninstalled 2 times and i cant change it. it wont let me change my song info please help

  • No thumbnails when I import a file

    When I import an mp4, imovie does not generate thumbnails--or show any evidence of the file at all. But when I look in Finder I see that the imported file is there under new projects. I'm afraid that I deleted some important component or something. S

  • MBP very slow to pick up signal after waking from sleep

    my MBP 2.33 takes about a minute after wake-up is complete to pick up a signal from the extreme N station (sits right next to it).....my old G3 ibook takes about 5sec....does anyone have a fix? the same problem? it is really annoying....it takes almo

  • Adobe reader update seem to come with Google chrome and toolbar I do not want these

    I do not want bloody google chrome or their toolbar why do you keep attaching it to updates If I want these I wopuld ask. I have a brain and know what i wany and what I dont  and staring to thing I would not buy any Adobe Products and would recomend