Performance issue in Select Query on ERCH

Dear Friends,
I have to execute a query on ERCH in production system having around 20 lakh data which keeps on increasing. "Select BELNR VERTRAG ADATSOLL from ERCH where BCREASON = u201803u2019 " . The expected volume of data that the query will return is approx 1400 records.
Since the where clause includes a field which is not a key field please suggest the performance of the query so that it doesn't time-out.
Regards,
Amit Srivastava

Hello Amit Srivastava ,
                                    You can add the Contract account number(VKONT)  and Business Partner number(GPARTNER) in your query and can create a custom Index for the contract account number  (We have this index created in our system).
This will improve the performance effectively.
Hope this answers your question.
Thanks,
Greetson

Similar Messages

  • Performance issue with select query

    Hi friends ,
    This is my select query which is taking so much time to retrive the records.CAn Any one help me in solving this performance issue.
    *- Get the Goods receipts  mainly selected per period (=> MKPF secondary
      SELECT msegebeln msegebelp mseg~werks
             ekkobukrs ekkolifnr ekkozterm ekkoekorg ekko~ekgrp
             ekkoinco1 ekkoexnum
             lfa1name1 lfa1land1 lfa1ktokk lfa1stceg
             mkpfmblnr mkpfmjahr msegzeile mkpfbldat mkpf~budat
             mseg~bwart
    *Start of changes for CIP 6203752 by PGOX02
             mseg~smbln
    *End of changes for CIP 6203752 by PGOX02
             ekpomatnr ekpotxz01 ekpomenge ekpomeins
             ekbemenge ekbedmbtr ekbewrbtr ekbewaers
             ekpolgort ekpomatkl ekpowebaz ekpokonnr ekpo~ktpnr
             ekpoplifz ekpobstae
             INTO TABLE it_temp
        FROM mkpf JOIN mseg ON msegmblnr EQ mkpfmblnr
                           AND msegmjahr EQ mkpfmjahr
                  JOIN ekbe ON ekbeebeln EQ msegebeln
                           AND ekbeebelp EQ msegebelp
                           AND ekbe~zekkn EQ '00'
                           AND ekbe~vgabe EQ '1'
                           AND ekbegjahr EQ msegmjahr
                           AND ekbebelnr EQ msegmblnr
                           AND ekbebuzei EQ msegzeile
                  JOIN ekpo ON ekpoebeln EQ ekbeebeln
                           AND ekpoebelp EQ ekbeebelp
                  JOIN ekko ON ekkoebeln EQ ekpoebeln
                  JOIN lfa1 ON lfa1lifnr EQ ekkolifnr
        WHERE mkpf~budat IN so_budat
          AND mkpf~bldat IN so_bldat
          AND mkpf~vgart EQ 'WE'
          AND mseg~bwart IN so_bwart
          AND mseg~matnr IN so_matnr
          AND mseg~werks IN so_werks
          AND mseg~lifnr IN so_lifnr
          AND mseg~ebeln IN so_ebeln
          AND ekko~ekgrp IN so_ekgrp
          AND ekko~bukrs IN so_bukrs
          AND ekpo~matkl IN so_matkl
          AND ekko~bstyp IN so_bstyp
          AND ekpo~loekz EQ space
          AND ekpo~plifz IN so_plifz.
    Thanks & Regards,
    Manoj Kumar .Thatha
    Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
    Edited by: Rob Burbank on Feb 4, 2010 9:03 AM

    Hi friends ,
    This is my select query which is taking so much time to retrive the records.CAn Any one help me in solving this performance issue.
    *- Get the Goods receipts  mainly selected per period (=> MKPF secondary
      SELECT msegebeln msegebelp mseg~werks
             ekkobukrs ekkolifnr ekkozterm ekkoekorg ekko~ekgrp
             ekkoinco1 ekkoexnum
             lfa1name1 lfa1land1 lfa1ktokk lfa1stceg
             mkpfmblnr mkpfmjahr msegzeile mkpfbldat mkpf~budat
             mseg~bwart
    *Start of changes for CIP 6203752 by PGOX02
             mseg~smbln
    *End of changes for CIP 6203752 by PGOX02
             ekpomatnr ekpotxz01 ekpomenge ekpomeins
             ekbemenge ekbedmbtr ekbewrbtr ekbewaers
             ekpolgort ekpomatkl ekpowebaz ekpokonnr ekpo~ktpnr
             ekpoplifz ekpobstae
             INTO TABLE it_temp
        FROM mkpf JOIN mseg ON msegmblnr EQ mkpfmblnr
                           AND msegmjahr EQ mkpfmjahr
                  JOIN ekbe ON ekbeebeln EQ msegebeln
                           AND ekbeebelp EQ msegebelp
                           AND ekbe~zekkn EQ '00'
                           AND ekbe~vgabe EQ '1'
                           AND ekbegjahr EQ msegmjahr
                           AND ekbebelnr EQ msegmblnr
                           AND ekbebuzei EQ msegzeile
                  JOIN ekpo ON ekpoebeln EQ ekbeebeln
                           AND ekpoebelp EQ ekbeebelp
                  JOIN ekko ON ekkoebeln EQ ekpoebeln
                  JOIN lfa1 ON lfa1lifnr EQ ekkolifnr
        WHERE mkpf~budat IN so_budat
          AND mkpf~bldat IN so_bldat
          AND mkpf~vgart EQ 'WE'
          AND mseg~bwart IN so_bwart
          AND mseg~matnr IN so_matnr
          AND mseg~werks IN so_werks
          AND mseg~lifnr IN so_lifnr
          AND mseg~ebeln IN so_ebeln
          AND ekko~ekgrp IN so_ekgrp
          AND ekko~bukrs IN so_bukrs
          AND ekpo~matkl IN so_matkl
          AND ekko~bstyp IN so_bstyp
          AND ekpo~loekz EQ space
          AND ekpo~plifz IN so_plifz.
    Thanks & Regards,
    Manoj Kumar .Thatha
    Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
    Edited by: Rob Burbank on Feb 4, 2010 9:03 AM

  • Performance issue with select query and for all entries.

    hi,
    i have a report to be performance tuned.
    the database table has around 20 million entries and 25 fields.
    so, the report fetches the distinct values of two fields using one select query.
    so, the first select query fetches around 150 entries from the table for 2 fields.
    then it applies some logic and eliminates some entries and makes entries around 80-90...
    and then it again applies the select query on the same table using for all entries applied on the internal table with 80-90 entries...
    in short,
    it accesses the same database table twice.
    so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
    is around 80-90 entries too much for using "for all entries"?
    the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
    i really cant find the way out...
    please help.

    chinmay kulkarni wrote:Chinmay,
    Even though you tried to ask the question with detailed explanation, unfortunately it is still not clear.
    It is perfectly fine to access the same database twice. If that is working for you, I don't think there is any need to change the logic. As Rob mentioned, 80 or 8000 records is not a problem in "for all entries" clause.
    >
    > so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
    >
    It is not clear what you tried to do here. Did you try to bring all 20 million records into an internal table? That will certainly cause the program to short dump with memory shortage.
    > the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
    >
    That is fine. Actually, it is better (performance wise) to do much of the work in ABAP than writing a complex WHERE clause that might bog down the database.

  • Performance issue in select query

    Moderator message: do not post the same question in two forums.  Duplicate (together with answers) deleted.
    SELECT a~grant_nbr
            a~zzdonorfy
            a~company_code
            b~language
          b~short_desc
    INTO TABLE i_gmgr_text
    FROM gmgr AS a
    INNER JOIN gmgrtexts AS b ON a~grant_nbr = b~grant_nbr
    WHERE a~grant_nbr  IN s_grant
    AND   a~zzdonorfy  IN s_dono
    AND   b~language   EQ sy-langu
    AND   b~short_desc IN s_cont.
    How to use for all all entries in the above inner join for better performance?
    then....
      IF sy-subrc EQ 0.
        SORT i_gmgr_text BY grant_nbr.
      ENDIF.
      IF i_gmgr_text[] IS NOT INITIAL.
    * Actual Line Item Table
        SELECT rgrant_nbr
               gl_sirid
               rbukrs
               rsponsored_class
               refdocnr
               refdocln
        FROM gmia
        INTO TABLE i_gmia
        FOR ALL ENTRIES IN i_gmgr_text
        WHERE rgrant_nbr        = i_gmgr_text-grant_nbr
        AND   rbukrs            = i_gmgr_text-company_code
        AND   rsponsored_class IN s_spon.
        IF sy-subrc EQ 0.
          SORT i_gmia BY refdocnr refdocln.
        ENDIF.
    Edited by: Matt on Dec 17, 2008 1:40 PM

    > How to use for all all entries in the above inner join for better performance?
    my best christmas recommendation for performance, simply ignore such recommendations.
    And check the performance of your join!
    Is the performance really low, if it is then there is probably no index support. Without indexes FOR ALL ENTRIES will be much slower.
    Siegfried

  • Performance issue on select query

    hi,
    Can any explain how the system behaves for the below 2 scenarios and which is much better?
    In table EABLG i have around 1 billion records (FYI)
    1)
        SELECT
              ablbelnr
              anlage
              ablesgr  
          FROM eablg
          INTO TABLE it_eablg
          FOR ALL ENTRIES IN it_eanl
          WHERE ( anlage = it_eanl-anlage
            AND  ablesgr = '01'           
            AND adatsoll GT  '20080706' )        " last 3 months
          OR    ( anlage = it_eanl-anlage
            AND  ablesgr = '06'
            AND adatsoll GT  '20080706' )       " last 3 months
    2)
    SELECT
              ablbelnr
              anlage
              ablesgr  
        FROM eablg
        INTO TABLE it_eablg
        FOR ALL ENTRIES IN it_eanl
        WHERE  anlage = it_eanl-anlage
        AND  (  ablesgr = '01'           
           OR     ablesgr = '06')         
       AND adatsoll GT '20080706'    .  " last 3 months
    thanks in advance.
    with regards
    sumanth

    The statement has to be in a special format, so it might make sense run a trace in DEV, check the "Explain" there and download/upload the statement to QA (also via ST05). I have not tried this myself yet, so I would be interested if it works
    Here is two resources for you, SAP online help and a good blog by Siegfried Boes:
    http://help.sap.com/saphelp_erp60_sp/helpdata/EN/d1/801f7c454211d189710000e8322d00/frameset.htm
    The SQL Trace (ST05) – Quick and Easy
    It's a very powerful analysis tool, so it's worth the time to work yourself into it.
    But again, you actually want good test data in DEV for this matter.
    Thomas

  • Performance issue while generating Query

    Hi BI Gurus.
    I am facing performance issue while generating query on 0IC_C03.
    It has a variable as (from & to) for generating the report for a particular time duration.
    if the variable (from & to) fields is filled then after taking a long time it shows run time error.
    & if the query is executed without mentioning the variable(which is optional) then the data is extracted from beginning to till date. the same takes less time in execution.
    & after that the period has to be selected manually by option keep filter value. please suggest how can i solve the error
    Regards
    Ritika

    HI RITIKA,
    WEL COME TO SDN.
    YOUHAVE TO CHECK THE FOLLOWING RUN TIME SEGMENTS USING ST03N TCODE:
    High Database Runtime
    High OLAP Runtime
    High Frontend Runtime
    if its high Database Runtime :
    - check the aggregates or create aggregates on cube and this helps you.
    if its High OLAP Runtime :
    - check the user exits if any.
    - check the hier. are used and fetching in deep level.
    If its high frontend runtime:
    - check if a very high number of cells and formattings are transferred to the Frontend ( use "All data" to get value "No. of Cells") which cause high network and frontend (processing) runtime.
    For From and to date variables, create one more set and use it and try.
    Regs,
    VACHAN

  • Need pointers to improve performance of a select query to table vbrk

    Hey Folks,
    I have a query , whose performance needs to be tuned , as such:
        SELECT a~vbeln
               a~fkart                    
               a~waerk
               a~fkdat                   
               b~posnr
               b~vgbel
               b~vgpos
               b~matnr
               b~arktx
               b~prctr
               b~txjcd
          INTO TABLE gi_billing_items
          FROM vbrk AS a
          INNER JOIN vbrp AS b
          ON a~vbeln = b~vbeln
          FOR ALL ENTRIES IN gi_sales_items
         WHERE b~vgbel = gi_sales_items-vbeln
           AND b~vgpos  = gi_sales_items-posnr
           AND b~matnr  = gi_sales_items-matnr
           AND b~werks  = gi_sales_items-werks.
    where
    gi_sales_items is an internal table consisting of 278 entries,.
    The result set collected in table gi_billing_items is 200 records
    The total execution time for this query for the afore given data is 72,983 ms with the average time/record being ~ 9,471 ms which is too high.
    When I try to verify the Explain Plan of the query in ST05, in the Access path I see that the performance of Query Block 1 is bad. Query Block 1 is of the QBLOCK_TYPE UNIONA. Its the very first step in the Query execution internally.
    The indexes are defined on participating tables VBRK and VBRP as:
    VBRK~0      MANDT,VBELN
    VBRK~LOC MANDT,LCNUM
    VBRP~0      MANDT,VBELN,POSNR
    VBRP~Z01   FPLNR,MANDT
    VBRP~Z02   MANDT,MATNR,WERKS
    Its clear from the ST05, STAD and SE30 traces that there is a performance issue in this query. Does anyone have any pointers as to how to resolve this issue? Is there a protocol one needs to follow when using the "FOR ALL ENTRIES IN" clause? Or is there a need for any secondary indexes to be created?
    Please let me know
    Thanks and Best Regards,
    Rashmi.

    Hi,
    Try using the VBFA...to get the Invoice number and line item..and then use that value in VBRK...
    * Declare the internal table for T_VBFA.
    IF NOT gi_sales_items[] IS INITIAL.
    SELECT VBELV
                  POSNV
                  VBELN
                  POSNN
                  VBTYP_N
                  INTO TABLE T_VBFA
                  FOR ALL ENTRIES IN gi_sales_items
                  WHERE VBELV = gi_sales_items-VBELN
                  AND       POSNV = gi_sales_items-POSNR
                  AND       VBTYP_N = 'M'.             "Invoice                       ""Added this..
    ENDIF.
    **Add two columns to GI_SALES_ITEMS..to store the VBELN POSNN the data from t_vbfa..let's assume it is VBELN_VF and POSNR_VF
    * Basically merge gi_sales_items AND t_vbfa
    ** Then use that field in
    IF NOT GI_SALES_ITEMS[] IS INITIAL.
          SELECT a~vbeln
               a~fkart                    
               a~waerk
               a~fkdat                   
               b~posnr
               b~vgbel
               b~vgpos
               b~matnr
               b~arktx
               b~prctr
               b~txjcd
          INTO TABLE gi_billing_items
          FROM vbrk AS a
          INNER JOIN vbrp AS b
          ON a~vbeln = b~vbeln
          FOR ALL ENTRIES IN gi_sales_items
          WHERE b~vbeln = gi_sales_items-vbeln_vf   " Change here
           AND b~posnr  = gi_sales_items-posnr_vf     " Change here
           AND b~matnr  = gi_sales_items-matnr
           AND b~werks  = gi_sales_items-werks.
    ENDIF.
    Thanks
    Naren
    Edited by: Narendran Muthukumaran on Oct 15, 2008 11:35 PM

  • Performance Issues in Text query.

    Hi,
    We are doing a text mining on a column which has been indexed as a "MULTI_COLUMN_DATASTORE" on two CLOB fields.
    While searching on this column, we face performance issues. The tables (both TABLE 1 and TABLE2) contains more than 46 million records. The query takes more than 10 minutes to execute.
    This is the query used:
    SELECT TABLE1.COLUMN1
    FROM TABLE1, TABLE2
    WHERE CONTAINS
    (TABLE2.CLOB_COLUMN,
    '(((({TEMPERATURE} OR {TEMP} OR {TEMPS} OR {THERMAL}) OR ({ENGINE} OR {ENG} OR {ENGINES})) AND (({SENSOR} OR {PROBE} OR {SEN} OR {SENSORS} OR {SENSR} OR {SNSR} OR {TRANSDUCER}))) AND (({INSTALL} OR {INST} OR {INSTALLATION} OR {INSTALLED} OR {INSTD} OR {INSTL} OR {INSTLD} OR {INSTN}) OR ({REMOVED} OR {REMOVAL} OR {REMOVE} OR {REMVD} OR {RMV} OR {RMVD} OR {RMVL}) OR ({REPLACED} OR {R+R} OR {R/I} OR {R/R} OR {REPL} OR {REPLACE} OR {REPLCD} OR {REPLD} OR {RM/RP} OR {RPL} OR {RPLCD} OR {RPLCED} OR {RPLD} OR {RPLED}) OR ({INOPERATIVE} OR {INOP}) OR ({FAILURE} OR {FAIL} OR {FAILD} OR {FAILED} OR {FAILR}) OR ({CHANGE} OR {CHANGED} OR {CHG} OR {CHGD} OR {CHGE} OR {CHGED}))) AND (({PRESSURE} OR {PRES} OR {PRESR} OR {PRESS} OR {PRESSURES} OR {PRESSURIZATION} OR {PRESSURIZE} OR {PRESSURIZED} OR {PRESSURIZING} OR {PRSZ} OR {PRSZD} OR {PRSZG} OR {PX})) NOT ({CARRIED} OR ({COOLANT} OR {COLNT}) OR ({DISPLAYED} OR {DSPLYD}))'
    ) > 0
    AND TABLE1.COLUMN1 = TABLE2.COLUMN1
    AND TABLE1.COLUMN2 = TABLE2.COLUMN2.
    We created the index using the following procedure:
    begin
    ctx_ddl.create_preference('my_alias', 'MULTI_COLUMN_DATASTORE');
    ctx_ddl.set_attribute('my_alias', 'columns', 'column1, column2, column3');
    end;
    create index index_name
    on table_name(column1)
    indextype is ctxsys.context
    parameters ('datastore ctxsys.my_alias');
    Please let me know if there are any optimization techniques that can be used to tune this query.
    Also, I would like to know if using "MULTI_COLUMN_DATASTORE" would cause performance issues. Will Query REWRITE improve the performance in this case?
    Thanks in Advance!

    What happens if you remove the join and just run the query against TABLE2?
    Try it without the join, and just fetch the first 100 records (or something) from the query and see how that performs.
    Have you optimized the index? Always worth doing after an index creation on a large table, especially as you've used the default index memory setting for the index.

  • Issue in select query

    HI All experts,<br><br>
    i have  a program in which i have a select query <pre>
    SELECT  b~vertrag
              a~anlage
              a~operand
              a~saison
              a~ab
              a~ablfdnr
              a~bis
              a~wert1
      FROM ettifn AS a INNER JOIN ever AS b
      ON aanlage = banlage
      INTO TABLE li_captran PACKAGE SIZE p_pack
      WHERE a~anlage IN s_anlage
        AND a~ab <= l_date
        AND a~bis >= l_date
        AND a~operand IN ('ID-CAPLOAD','ID-OBLT')
        AND b~einzdat <= l_date
        AND b~auszdat >= l_date.</pre><br><br>
    this query is taking a lot of time in running and we are facing lot of performance related issues
    <br><br>
    kindly guide me how i can break this into som simpler query
    <br><br>
    ettifn has 10 million records
    ever has around 5 million records .
    <br><br>
    also please tell me how much data i can store into an internal table
    can i store 5 million records in an internal table ??????
    is it good in terms of performance of a program if not please tell me what is the better way of doing dat .
    <br><br>
    also tell me how secondry indexes help in improving performance of select query
    is it good to maintain number of secondry indexes in a standard table or it decreases performance of a standard table .
    <br><br>
    <pre>
      TYPES: BEGIN OF ty_eanlh,
              anlage LIKE eanlh-anlage,
              bis LIKE eanlh-bis,
              tariftyp LIKE eanlh-tariftyp,
             END OF ty_eanlh.
      DATA: l_date TYPE datum.
      DATA: li_eanlh TYPE HASHED TABLE OF ty_eanlh WITH UNIQUE KEY anlage
                                                                   bis
                                                   WITH HEADER LINE.
      DATA: li_captran TYPE HASHED TABLE OF ty_captran WITH UNIQUE KEY vertrag
                                                                       anlage
                                                                       operand
                                                                       saison
                                                                       ab
                                                                       ablfdnr
                                                        WITH HEADER LINE.
      DATA: l_tariftyp LIKE eanlh-tariftyp.
    l_date = p_date + 6.
      l_date = p_date + 5.          "As per Terry's Request 1/23/2009
      CHECK NOT p_cap IS INITIAL.
    Get Operand Values
      SELECT  b~vertrag
              a~anlage
              a~operand
              a~saison
              a~ab
              a~ablfdnr
              a~bis
              a~wert1
      FROM ettifn AS a INNER JOIN ever AS b
      ON aanlage = banlage
      INTO TABLE li_captran PACKAGE SIZE p_pack
      WHERE a~anlage IN s_anlage
        AND a~ab <= l_date
        AND a~bis >= l_date
        AND a~operand IN ('ID-CAPLOAD','ID-OBLT')
        AND b~einzdat <= l_date
        AND b~auszdat >= l_date.
        IF sy-subrc EQ 0 AND NOT li_captran[] IS INITIAL.
       Get Rate Category
          SELECT anlage
                 bis
                 tariftyp
          FROM eanlh INTO CORRESPONDING FIELDS OF TABLE li_eanlh
          FOR ALL ENTRIES IN li_captran
          WHERE anlage = li_captran-anlage
            AND ab <= l_date
            AND bis >= l_date.
       Get POD ID
          SELECT a~anlage
                 a~int_ui
                 a~dateto
                 a~timeto
                 b~ext_ui
          INTO TABLE i_pod
          FROM euiinstln AS a INNER JOIN euitrans AS b
          ON aint_ui = bint_ui
          FOR ALL ENTRIES IN li_captran
          WHERE a~anlage = li_captran-anlage.
          IF sy-subrc EQ 0 AND NOT i_pod[] IS INITIAL.
            SORT i_pod BY anlage.
            SELECT vertrag
                   int_ui
                   serviceid
            FROM eservice
            INTO TABLE i_servicect
            FOR ALL ENTRIES IN i_pod
            WHERE int_ui = i_pod-int_ui
              AND service_start <= l_date
              AND service_end >= l_date
              AND service = 'ESUP'.
          ENDIF.
          LOOP AT li_captran.
            i_ct-anlage = li_captran-anlage.
            READ TABLE li_eanlh WITH KEY anlage = li_captran-anlage.
            IF sy-subrc EQ 0.
              i_ct-tariftyp = li_eanlh-tariftyp.
              READ TABLE i_rate WITH KEY tariftyp = i_ct-tariftyp.
              IF sy-subrc NE 0.
                CONTINUE.
              ENDIF.
            ELSE.
              i_ct-tariftyp = '0000'.
            ENDIF.
            READ TABLE i_pod WITH KEY anlage = li_captran-anlage.
            IF sy-subrc EQ 0.
              READ TABLE i_servicect WITH KEY int_ui = i_pod-int_ui.
              IF sy-subrc EQ 0.
                i_ct-serviceid = i_servicect-serviceid.
              ENDIF.
            ENDIF.
            IF li_captran-operand = 'ID-CAPLOAD'.
              i_ct-cap = li_captran-wert1.
            ELSEIF li_captran-operand = 'ID-OBLT'.
              i_ct-tran = li_captran-wert1.
            ENDIF.
            COLLECT i_ct.
            CLEAR: li_captran, i_ct.
          ENDLOOP.
        ENDIF.
      ENDSELECT.</pre><br><br>
      this code is taking a lot of time to execute and decreasing the system performance .<br><br>
    please guide me how can i increase the performance of this code .<br><br>
    Thanks in advance<br><br><br><br>
    Edited by: Matt on Oct 11, 2009 9:45 PM

    Hi matt ,
    no i am not thru bcoz of formatting i just trying to remove it and i just marked it answered so that it will not come in my unanswered because unanswered questions are limited.
    also could you please help me in this question .
    now how can i change this question to unanswerd .
    plz guide me
    Thanks in advance

  • Performance issue while selecting material documents MKPF & MSEG

    Hello,
    I'm facing performance issues in production while selecting Material documents for Sales order and item based on the Sales order Stock.
    Here is the query :
    I'm first selecting data from ebew table which is the Sales order Stock table then this query.
        IF ibew[] IS NOT INITIAL AND ignore_material_documents IS INITIAL.
    *     Select the Material documents created for the the sales orders.
          SELECT mkpf~mblnr mkpf~budat
                 mseg~matnr mseg~mat_kdauf mseg~mat_kdpos mseg~shkzg
                 mseg~dmbtr mseg~menge
           INTO  CORRESPONDING FIELDS OF TABLE i_mseg
           FROM  mkpf INNER JOIN mseg
           ON    mkpf~mandt = mseg~mandt
           AND   mkpf~mblnr = mseg~mblnr
           AND   mkpf~mjahr = mseg~mjahr
           FOR   ALL entries IN ibew
           WHERE mseg~matnr      = ibew-matnr
           AND   mseg~werks         = ibew-bwkey
           AND   mseg~mat_kdauf   = ibew-vbeln
           AND   mseg~mat_kdpos  = ibew-posnr.
          SORT i_mseg BY mat_kdauf ASCENDING
                         mat_kdpos ASCENDING
                         budat     DESCENDING.
        ENDIF.
    I need to select the material documents because the end users want to see the stock as on certain date for the sales orders and only material document lines can give this information. Also EBEW table gives Stock only for current date.
    For Example :
    If the report was run for Stock date 30th Sept 2008, but  on the 5th Oct 2008, then I need to consider the goods movements after 30th Sept and add if stock was issued or subtract if stock was added.
    I know there is an Index MSEG~M in database system on mseg, however I don't know the Storage location LGORT and Movement types BWART that should be considered, so I tried to use all the Storage locations and Movement types available in the system, but this caused the query to run even slower than before.
    I could create an index for the fields mentioned in where clause , but it would be an overhead anyways.
    Your help will be appreciated. Thanks in advance
    regards,
    Advait

    Hi Thomas,
    Thanks for your reply. the performance of the query has significantly improved than before after switching the join from mseg join mkpf.
    Actually, I even tried without join and looped using field symbols ,this is working slightly faster than the switched join.
    Here are the result ,  tried with 371 records as our sandbox doesn't have too many entries unfortunately ,
    Results before switching the join  146036 microseconds
    Results after swithing the join        38029 microseconds
    Results w/o join                           28068 microseconds for selection and 5725 microseconds for looping
    Thanks again.
    regards,
    Advait

  • Performance Issue with Selection Screen Values

    Hi,
    I am facing a performance issue(seems like a performance issue ) in my project.
    I have a query with some RKFs and sales area in filters (single value variable which is optional).
    Query is by default  restricted by current month.
    The Cube on which the query operates has around 400,000 records for a month.
    The Cube gets loaded every three hours
    When I run the query with no filters I get the output within 10~15 secs.
    The issue I am facing is that,  when I enter a sales area in my selection screen the query gets stuck in the data selection step. In fact we are facing the same problem if we use one or two other characteristics in our selection screen
    We have aggregates/indexes etc on our cube.
    Has any one faced a similar situation?
    Does any one have any comments on this ?
    Your help will be appreciated. Thanks

    Hi A R,
    Goto RSRT--> Give ur query anme --> Execute =Debug
    --> No a pop up ill come with many check boxes select "Display Aggregates found" option --> now give ur
    selections in variable screen > first it will give the already existing aggregate names> continue> now after displaying all the aggregates it will display the list of objects realted to cube wise> try to copy these objects into notepad> again go with ur drill downs now u'll get the already existing aggregates for this drill down-> it will display the list of objects> copy them to notepad> now sort all the objects related to one cube by deleting duplicate objects in the note pad>goto that Infocube> context>maintain aggregates> create aggregate on the objects u copied into note pad.
    now try to execyte the report... it should work properly with out delays for those selections.
    I hope it helps you...
    Regards,
    Ramki.

  • Performance Issue on Select Condition on KNA1 table

    Hi,
    I am facing problem when i am selecting from the table KNA1 for given account group and attribute9 it is taking lot of time .
    Please suggest the select query or any other feasible soln to solve this problem
    select
    kunnr
    kotkd
    from kna1
    where kunnr eq parameter value and
    kotkd eq 'ZPY' and katr9 = 'L' or 'T'.
    Firstly i am using in in katr9 then i removed dur to performance issue using read further please suggest further performanace soln

    Hi,
    The select should be like:
    select
    kunnr
    kotkd
    from kna1
    where kunnr eq parameter value
        and kotkd eq 'ZPY'
         and katr9 in r_katr9. "  'L' or 'T'.
    create a range for katr9 like r_katr9 with L or T.
    Because while selecting the entries from KNA1, it will check for KATR9 = L and then KATR9 = T.
    Hope the above statement is useful for you.
    Regards,
    Shiva.

  • Poor performance due to select query

    Hey ppl,
    I am facing a problem in one of the select query on BSEG.
    The query is as given
    TYPES :BEGIN OF wa1_bseg,
            bukrs    TYPE bseg-bukrs,
            belnr     TYPE bseg-belnr,     
            gjahr         TYPE bseg-gjahr,
            buzei    TYPE bseg-buzei,
            fwbas    TYPE bseg-fwbas ,     
            pswbt    TYPE bseg-pswbt,
            hkont    TYPE bseg-hkont,
            wrbtr     TYPE bseg-wrbtr,
            ktosl     TYPE bseg-ktosl,
            koart     TYPE bseg-koart,
            shkzg    TYPE bseg-shkzg,
            mwskz   TYPE bseg-mwskz,
            qsskz    TYPE bsis-qsskz,
            dmbtr     TYPE bseg-dmbtr,
            flag        TYPE C,
            END OF wa1_bseg.
    DATA: it_bsegv TYPE TABLE OF wa1_bseg WITH HEADER LINE.
    SELECT bukrs belnr gjahr buzei fwbas pswbt hkont wrbtr  ktosl shkzg koart mwskz
    FROM bseg INTO TABLE it_bsegv
    FOR ALL ENTRIES IN it_ekko
       WHERE bukrs = 'MU51'     AND
                    gjahr IN s_fiscal    AND
                    valut IN s_budat1  AND
                    ebeln = it_ekko-ebeln.
    Even if there are only around 5 records in it_ekko it takes very long time in executing. Sumtimes it even shows 'time out' in
    foreground.   Kindly help me out with it

    Hi,
    Go through this link it will helpful,
    Re: Performance Issue with BKPF, BSEG, BSET
    Re: Reading BSEG: performance problems
    /people/rob.burbank/blog/2007/11/12/quickly-retrieving-fi-document-data-from-bseg
    Regards
    Adil
    Edited by: Syed  Abdul Adil on Jun 17, 2008 12:33 PM

  • Performance of the select query

    i want to know wheter the conversion of  the select query
    SELECT  * FROM mchb                        
            WHERE matnr EQ mch1-matnr
            AND   charg EQ mch1-charg
            AND   werks EQ plant-werks.
            itab-lgort = mchb-lgort.
            itab-clabs = mchb-clabs.
            APPEND itab.
          ENDSELECT.
    into following pattern
    select lgort clabs
           from mchb
           into corresponding fields of itab
           WHERE matnr EQ mch1-matnr
           AND   charg EQ mch1-charg
           AND   werks EQ plant-werks.
           ENDSELECT.
    will give  the same results ?

    Hi,
    It will results in performance issue because of end select statement.
    select lgort clabs
         from mchb
            into table itab
            WHERE matnr EQ mch1-matnr
                  AND charg EQ mch1-charg
                  AND werks EQ plant-werks.
    Use like this you will get the values of lgort and clabs in the internal table itab.
    Then use loop statement to use that values further.
    Dont use end select it will be a performance issue.
    In this code there is no need to use of ENDSELECT and use corresponding fields of table itab.
    select lgort clabs
    from mchb
    into corresponding fields of itab
    WHERE matnr EQ mch1-matnr
    AND charg EQ mch1-charg
    AND werks EQ plant-werks.
    ENDSELECT.
    Thanks,
    Sakthi

  • Performance Issue with sql query

    Hi,
    My db is 10.2.0.5 with RAC on ASM, Cluster ware version 10.2.0.5.
    With bsoa table as
    SQL> desc bsoa;
    Name                                      Null?    Type
    ID                                        NOT NULL NUMBER
    LOGIN_TIME                                         DATE
    LOGOUT_TIME                                        DATE
    SUCCESSFUL_IND                                     VARCHAR2(1)
    WORK_STATION_NAME                                  VARCHAR2(80)
    OS_USER                                            VARCHAR2(30)
    USER_NAME                                 NOT NULL VARCHAR2(30)
    FORM_ID                                            NUMBER
    AUDIT_TRAIL_NO                                     NUMBER
    CREATED_BY                                         VARCHAR2(30)
    CREATION_DATE                                      DATE
    LAST_UPDATED_BY                                    VARCHAR2(30)
    LAST_UPDATE_DATE                                   DATE
    SITE_NO                                            NUMBER
    SESSION_ID                                         NUMBER(8)
    The query
    UPDATE BSOA SET LOGOUT_TIME =SYSDATE WHERE SYS_CONTEXT('USERENV', 'SESSIONID') = SESSION_ID
    Is taking a lot of time to execute and in AWR reports also it is on top in
    1. SQL Order by elapsed time
    2. SQL order by reads
    3. SQL order by gets
    So i am trying a way to solve the performance issue as the application is slow specially during login and logout time.
    I understand that the function in the where condition cause to do FTS, but i can not think what other parts to look at.
    Also:
    SQL> SELECT COUNT(1) FROM BSOA;
      COUNT(1)
       7800373
    The explain plan for  "UPDATE BSOA SET LOGOUT_TIME =SYSDATE WHERE SYS_CONTEXT('USERENV', 'SESSIONID') = SESSION_ID" is
    {code}
    PLAN_TABLE_OUTPUT
    Plan hash value: 1184960901
    | Id  | Operation          | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT   |                    |     1 |    26 | 18748   (3)| 00:03:45 |
    |   1 |  UPDATE            | BSOA |       |       |            |          |
    |*  2 |   TABLE ACCESS FULL| BSOA |     1 |    26 | 18748   (3)| 00:03:45 |
    Predicate Information (identified by operation id):
       2 - filter("SESSION_ID"=TO_NUMBER(SYS_CONTEXT('USERENV','SESSIONID')))
    {code}

    Hi,
    There are also triggers before update and AUDITS on this table.
    CREATE OR REPLACE TRIGGER B2.TRIGGER1
    BEFORE UPDATE
    ON B2.BSOA  REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW
    :NEW.LAST_UPDATED_BY   := USER    ;
    :NEW.LAST_UPDATE_DATE  := SYSDATE ;
    END;
    CREATE OR REPLACE TRIGGER B2.TRIGGER2
    BEFORE INSERT
    ON B2.BSOA  REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW
    :NEW.CREATED_BY        := USER ;
    :NEW.CREATION_DATE     := SYSDATE ;
    :NEW.LAST_UPDATED_BY   := USER    ;
    :NEW.LAST_UPDATE_DATE  := SYSDATE ;
    END;
    And also there is an audit on this table
    AUDIT UPDATE ON B2.BSOA BY ACCESS WHENEVER SUCCESSFUL;
    AUDIT UPDATE ON B2.BSOA BY ACCESS WHENEVER NOT SUCCESSFUL;
    And the sessionid column in BSOA has height balanced histogram.
    When i create an index i get the following error. As i am on 10g I can't use DDL_LOCK_TIMEOUT . I may have to wait for next down time.
    SQL> CREATE INDEX B2.BSOA_SESSID_I ON B2.BSOA(SESSION_ID) TABLESPACE B2 COMPUTE STATISTICS;
    CREATE INDEX B2.BSOA_SESSID_I ON B2.BSOA(SESSION_ID) TABLESPACE B2 COMPUTE STATISTICS
    ERROR at line 1:
    ORA-00054: resource busy and acquire with NOWAIT specified
    Thanks

Maybe you are looking for

  • How do I find whatever a "J2SE Installation" is?

    The raptor script (on Fedora Core 4 Linux) asks me to "Type the full pathname of a J2SE installation". I have searched for anything beginning with J2SE or j2se and come up empty. I have also installed the Sun JDK and provided the path to tht installa

  • Not able to display the image on the popup.

    hi, my requirement is: i have command link on the form.which on clicked should display a popup and with in that popup a image should be shown. I have stored that image in the form of byte array. On clicking the link i am able to show the popup.But,no

  • Alpha Channel Settings keep reverting back to "Ignore"

    Hey All, Just diving into FCPX and I had a question about the alpha channel. After finding the Alpha setting in the inspector, I switched to it premultiply. However, upon clicking out of it, the inspector reverts back to "ignore alpha." It does this

  • Trying to find out what processes are executing in Win2k

    I am trying to determine if a given background process is running in Win2k. It is a device driver I use for communications that does not create a window, so I cannot use the vi's that look for window names. Obviously, the program name does not show u

  • Apple TV reset date and time

    How do I reset date and time?