Avoiding performance issue due to loop within loop on internal tables

Hi Experts,
                I have a requirement where in i want to check whether each of the programs stored in one internal table are called from any of the programs stored in another internal table. In this case i am looping on two internal tables (Loop within a loop) which is causing a major performance issue. Program is running very very slow.
Can any one advise how to resolve this performance issue so that program runs faster.
Thanks in advance.
Regards,
Chetan.

Forget the parallel cursur stuff, it is much to complicated for general usage and helps nearly nothing. I will publish a blog in the next days where this is shown in detail.
Loop on loop is no problem if the inner table is a hashed or sorted table.
If it must be a standard table, then you must make a bit more effort and faciliate a binary search (read binary search / loop from index exit)
see here the exact coding Measurements on internal tables: Reads and Loops:
/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables
And don't forget, the other table must not be sorted, the loop reaches anyway every line. The parallel cursor requires both tables to be sorted. The additional sort
consumes nearly the whole advantage of the parallel cursor compared to the simple but good loop in loop solutions.
Siegfried

Similar Messages

  • How to update this query and avoid performance issue?

    Hi, guys:
    I wonder how to update the following query to make it weekend day aware. My boss want the query to consider business days only. Below is just a portion of the query:
    select count(distinct cmv.invoicekey ) total ,'3' as type, 'VALID CALL DATE' as Category
    FROM cbwp_mv2 cmv
    where cmv.colresponse=1
    And Trunc(cmv.Invdate)  Between (Trunc(Sysdate)-1)-39 And (Trunc(Sysdate)-1)-37
    And Trunc(cmv.Whendate) Between cmv.Invdate+37 And cmv.Invdate+39the CBWP_MV2 is a materialized view to tune query. This query is written for a data warehouse application, the CBWP_MV2 will be updated every day evening. My boss wants the condition in the query to consider only business days, for example, if (Trunc(Sysdate)-1)-39 falls in weekend, I need to move the range begins from next coming business day, if (Trunc(Sysdate)-1)-37 falls in weekend, I need to move the range ends from next coming business day. but I should always keep the range within 3 business days. If there is overlap on weekend, always push to later business days.
    Question: how to implement it and avoid performance issue? I am afraid that if I use a function, it greatly reduce the performance. This view already contains more than 100K rows.
    thank you in advance!
    Sam
    Edited by: lxiscas on Dec 18, 2012 7:55 AM
    Edited by: lxiscas on Dec 18, 2012 7:56 AM

    You are already using a function, since you're using TRUNC on invdate and whendate.
    If you have indexes on those columns, then they will not be used because of the TRUNC.
    Consider omitting the TRUNC or testing with Function Based Indexes.
    Regarding business days:
    If you search this forum, you'll find lots of examples.
    Here's another 'golden oldie': http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:185012348071
    Regarding performance:
    Steps to take are explained from the links you find here: {message:id=9360003}
    Read them, they are more than worth it for now and future questions.

  • Performance issue: CALL FUNCTION inside a Loop.

    Hi Friends
    I have a Performance Issue. That is, inside a loop...endloop a CALL FUNCTION has been used which gets data from another database table. Finally it's appended into another internal table. Please see this :
      LOOP AT i_mdkp.
        REFRESH lt_mdtbx.
        CLEAR lt_mdtbx.
        CALL FUNCTION 'READ_MRP_LIST'
          EXPORTING
            idtnum        = i_mdkp-dtnum
            icflag        = 'X'
          tables
            mdtbx         = lt_mdtbx
        APPEND LINES OF lt_mdtbx TO i_mdtb.
      ENDLOOP.
    It happens for each record available in i_mdkp. Suppose, i_mdkp have around 50000 records, it needs to call the function module till that much time.
    So, I want to split it. Can I?
    Please give me your valueable suggestions.
    Regards
    Senthil

    If internal table i_mdkp has 50,000 records it does not mean that you need to run 50,000 iterations. You just need dtnum from internal table i_mdkp so you number of iterations should be eqaul to the unique number of dtnum in the internal table. Sort the internal table by dtnum and delete adjacent duplicates from the internal table comparing dtnum before looping. Look at the code below.
    DATA i_mdkp_tmp LIKE TABLE OF i_mdkp.
    IF NOT i_mdkp[] IS INITIAL.
      i_mdkp_tmp[] = i_mdkp[].
      SORT i_mdkp BY dtnum.
      DELETE ADJACENT DUPLICATES FROM i_mdkp COMPARING dtnum.
      REFRESH i_mdtb.
      LOOP AT i_mdkp.
        CALL FUNCTION 'READ_MRP_LIST'
          EXPORTING
            idtnum = i_mdkp-dtnum
            icflag = 'X'
          TABLES
            mdtbx = lt_mdtbx.
        APPEND LINES OF lt_mdtbx TO i_mdtb.
        REFRESH lt_mdtbx.
      ENDLOOP.
      i_mdkp[] = i_mdkp_tmp[]
    ENDIF.

  • Cisco ASR 1002- performance issue due to access list

    Hi,
    We are planning to implement inbound access-list to block subnets from particular country. Since the subnets are not contiguous, we have about 16000 lines of acl entries.
    I want to know, would there be any performance or latency issues after applying 16k lines of acl?
    Is there a good document where I can read more about ACL limitations and performance issues on ASR.
    This is for ASR1002, running IOS-XE 15.3(1)S1.
    Thanks

    Disclaimer
    The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
    Liability Disclaimer
    In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
    Posting
    Sorry, I don't know the answer to your questions, but I'm writing to mention a 7200 feature, that if supported on the ASR, might help in your situation.  See http://www.cisco.com/c/en/us/support/docs/security/ios-firewall/23602-confaccesslists.html#turbo

  • Performance issue due to RFC calls. (R/3 to R/3 system)

    Hi,
    My application face serious performance problem because of RFC calls (R/3 system to R/3 system).
    1)is there any transaction code for doing performance analysis on RFC calls in R/3 system?
    2)How far large volume of Data Transfer (mainly due to internal tables) in a RFC call affects the performance? is there any limit for data transfer size at a time in a RFC call? if so how to calculate for best performance?
    Thanks and regards,
    Prakash.

    Hi Andreas,
    Suppose an RFC enabled Fm having an internal table as importing parameter.During execution of this Fm with 4000 enteries for the internal table results in performance degrading.is there any way to improve the performance?.
    Thanks and regards,
    Prakash.

  • System performance issue due to multiple submission of a job

    For month end recoincilation users run few critical reports which are quite resource consuming.
    In order to control this, want to restrict the usage of such  reports. For example if one session is active (Foreground or background) user couldn't submit another job or gets a pop up with an error mesage.
    Searched SDN for this and couldn't find much.
    anya

    Anya since this is the ABAP forum and I happen to be an ABAP programmer I can give you an ABAP solution. This would involve changes to the code in all these reports so you would need the help of an ABAP programmer if you are not one.
    a) Create a Z table containing 3 fields
    1) Client of type MANDT  (Primary key field)
    2)Program Name  of type PROGRAM_ID (Primary key field)
    3) User name of type XUBNAME (Regular field).
    b) Create table maintenance for this internal table.
    c) Create one record for each of the programs you want to regulate. You only need to enter the program name initially and leave the user name blank.
    d) In all the ABAP programs make the following change.
    1) Under the START-OF-SELECTION event of the report lock the use function module ENQUEUE_E_TABLEE to lock the record in the Ztable for the program being executed. Look at the sample code below.
    TABLES: <ztable>.
    data: w_message(100) TYPE c,
            w_locked(1) TYPE c.
    CALL FUNCTION 'ENQUEUE_E_TABLEE'
      EXPORTING
        tabname              = <ztable name>
        varkey               = <concatenation of mandt and sy-cprog>
      EXCEPTIONS
       foreign_lock         = 1
       system_failure       = 2
       OTHERS               = 3.
    IF sy-subrc EQ 1.
      SELECT SINGLE *
        FROM <ztable>
        INTO <ztable>
        WHERE program FIELD name EQ sy-cprog.
      IF sy-subrc EQ 0.
        CONCATENATE 'Program'
                    sy-cprog
                    'is currently being used by'
                    <ztable>-<user name>
          INTO w_message SEPARATED BY space.
        MESSAGE e208(00) WITH w_message.
      ENDIF.
    ELSEIF sy-subrc EQ 0.
      w_locked = 'X'.
      SELECT SINGLE *
        FROM <ztable>
        INTO <ztable>
        WHERE program FIELD name EQ sy-cprog.
      IF sy-subrc EQ 0.
        <ztable>-user name> = sy-uname.
        MODIFY <ztable> FROM <ztable>.
      ENDIF.
    ENDIF.
    e) At the event END-OF-SELECTION (at the end of the program) use function module DEQUEUE_E_TABLEE to unlock the record. Look at sample code below.
    CASE w_locked.
      WHEN 'X'.
        CALL FUNCTION 'DEQUEUE_E_TABLEE'
          EXPORTING
            tabname          = <ztable name>
            varkey             = <concatenation of mandt and sy-cprog>.
    ENDCASE.
    This code is designed to allow just one user or job to run the program at a time. The second person will be issued an error message informing him/her that the program is being used by <user name>.

  • Performance issue during SharePoint list data bind to html table using Ajax call(Rest API)

    Hello,
    I am having multiple lists in my SharePoint Site. I am using SharePoint REST APIs to get data from these lists and bind a HTML Table. Suppose, I have 5 lists with 1000 records each, I am looping 5000 times to bind each row(record) to this html table. This
    is causing performance issue which is taking a very long time to bind. 
    Is there any way So that I can reduce this looping OR is there any better approach to improve the performance. Please kindly Suggest.  Thank you for your help :)
    Warm Regards,
    Ratan Kumar Racha

    Hi Racha,
    For handling large data binding in a page,
    AngularJS would be a great option if you might would worry about the performance.
    You can get more information about using AngularJS from the two links below:
    https://www.airpair.com/angularjs/posts/angularjs-performance-large-applications
    http://www.sitepoint.com/10-reasons-use-angularjs/
    Best regards
    Patrick Liang
    TechNet Community Support

  • Loop using index read ( internal table)

    Hi,
    I thought of impelementing loop at ITAB using read statements, Here it goes.
    REPORT Z_LOOP_IMPROVE.
    DATA : T_OUTPUT TYPE STANDARD TABLE OF MARC WITH HEADER LINE,
    L_TABIX TYPE SY-TABIX.
    DEFINE ILOOP.
    DO.
    IF SY-INDEX EQ '1'.
    READ TABLE &1 WITH KEY &2 = &3 BINARY SEARCH.
    IF SY-SUBRC <> 0.
    EXIT.
    ENDIF.
    ELSE.
    L_TABIX = SY-TABIX + 1.
    READ TABLE &1 INDEX L_TABIX.
    IF SY-SUBRC NE 0 OR &1-&2 NE &3.
    EXIT.
    ENDIF.
    ENDIF.
    END-OF-DEFINITION.
    DEFINE IENDLOOP.
    ENDDO.
    END-OF-DEFINITION.
    DATA : T1 TYPE I, T2 TYPE I.
    SELECT * FROM MARC INTO TABLE T_OUTPUT.
    SORT T_OUTPUT BY WERKS.
    GET RUN TIME FIELD T1.
    ILOOP T_OUTPUT WERKS '0001'.
    WRITE : / T_OUTPUT-MATNR, T_OUTPUT-WERKS.
    IENDLOOP.
    GET RUN TIME FIELD T2.
    T2 = T2 - T1.
    WRITE : / T2.
    *C----
    But sadly it takes more time than a normal loop with
    where condition.
    can anyone suggest some ideas to improve execution speed?

    You can use a binary read to get the first record. Then read each record sequentially until you have proccessed all the records that meet your critera. You will have to have the internal table sorted so that the binary search and subsequent reads will work:
          READ TABLE itab WITH KEY
            field = whatever
            BINARY SEARCH.
          IF sy-subrc = 0.
            itab_index = sy-tabix.
            DO.
              IF sy-subrc = 0.
                IF itab_data-field = whatever
                  itab_index = itab_index + 1.
                  READ TABLE itab_data INDEX itab_index.
                ELSE.
                  EXIT.
                ENDIF.
              ELSE.
                EXIT.
              ENDIF.
            ENDDO.
          ENDIF.
    Rob

  • Loop fields in an internal table

    Dear experts,
    I have a scenario where I have an internal table (created in an end routine) c of felds that are both characteristics and key figures. I would like to do is to modify this table so that I keep the value of the charactersitics but I set the value of all the key figures to 0. How can I acomplish this and what is the best way? Is there for example a way to loop all the fields in the work area when I am looping though the internal table and then dependant on the data type, set the key figues = 0?
    Thanks!
    -Cathrin

    Hi Cathrin,
    It will not be possible to set the key figures to zero based on data type.
    You will have to set each key figure in the loop.
    Example:
    LOOP ITAB INTO WA_ITAB.
        WA_ITAB-KEYFIGURE1 = 0.
        WA_ITAB-KEYFIGURE2 = 0.
        MODIFY ITAB FROM WA_ITAB.
    ENDLOOP.
    Regards,
    Hemant Khemani

  • Looping over fields from internal table

    In a FM I have to check records of two ITABs against each other. Most fields can be checked 1:1 but some must be checked according to some business logic.
    I first want to check field-by-field and then I want to deal with exceptions.
    Question: How can I loop over fields in an ITAB in such a manner that I can compare fields?

    Hi, you can loop thru the columns(fields) of an internal table like so.
    field-symbols: <fs>.
    loop at itab.
    do.
    * Here you can use the field name instead of SY-INDEX
       assign component sy-index of structure itab to <fs>.
       if sy-subrc <>.
       exit.
       endif.
    * Now that you have access to the field via field symbol, you can compare
    * this value.
    Write:/ <fs>.
    enddo. 
    endloop.
    Regards,
    Rich Heilman

  • Loop break in an Internal table

    Hello,
    I have an internal table with many vendors and each vendor may have multiple line items. Now if a line item has incorrect data then that vendor shudnt get created and move on to the next vendor..As i show here
    v1,12,ea,3444
    v1,12,ea,3445
    v1,12,ea,3446
    v2,12,ea,3448
    v2,12,ea,3447
    If 3445 is incorrect then I shud move on to next vendor v2..How do i do this in an internal table.
    Thanks
    Viky

    Hi,
    You can make use of the AT control statements, something like this:
    Loop at itab.
    Check if the line item is ok.
    IF OK.
      flag = Y.
    ELSE.
      CONTINUE.
    ENDIF.
    AT END OF <vendor>.
    check flag = Y.
    Send vendor details.
    ENDAT.
    Endloop.
    Hope this helps,
    Sumant.

  • Performance issue due to column formula and filters

    Hi,
    I am facing strange issue with performance for my OBIEE reports. I have two sets of reports Static and Dynamic. Both runs against same tables. The only difference between these reports is that the Static reports would run against all the data for given aggregation level e.g. Year, Month, Date and so on. Where as for Dynamic one I have range prompts to filter data. Other difference is that I have a column formula for one of the column in the Dynamic report, which is nothing but Go URL to show another page with certain parameters.
    The static report takes around 14-15 Seconds where as the Dynamic one takes around 3.5 min. The amount of data and range is same here. From the logs I could see that for the Static reports, i.e. reports without filters it applys group by at SQL level where as it is not doing so for the dynamic one. Is this expected ?
    Second issue is, even if I say remove the filters and just have report with column formula in one and no formula in other there is significant time difference in the processing at Presentation service layer. Again this is taken from the log. it takes 8 second to get data from DB but shows almost 218 Seconds as response time at Presentation layer.
    Below are conceptual details about table and reports -
    Table 1 (It is date dimension) : Date_Dim
    DateCode Date
    Day Number
    MonthCode Varchar2
    YearCode Varchar2
    Table 2 (It is aggregate table at year level) : Year_Aggr
    DateCode Date (FK to Table1 above)
    Measure1
    Measure2
    Measure3
    Measure4
    Measure5
    Report 1
    Date_Dim.YearCode | Year_Aggr.Measure1 | Year_Aggr.Measure2 | Year_Aggr.Measure3 | Year_Aggr.Measure4
    Report 2
    Dashboard Filter : Dimension1 | Dimension2 | Year Start | Year End |
    Date_Dim.YearCode | Year_Aggr.Measure1 | Year_Aggr.Measure2 | Year_Aggr.Measure3 | Year_Aggr.Measure4
    Column formula for Date_Dim.YearCode is something like :
    '<a href="saw.dll?Dashboard&PortalPath=somepath and parameters  target=_self>'  || Date Dim"."YearCode" || '</a">'
    Filters :
    Dimension1 is prompted...
    Dimension2 is prompted...
    cast("Date Dim"."YearCode" as Int) is greater than or equal to @{Start_Year}
    cast("Date Dim"."YearCode" as Int) is greater than or equal to @{End_Year}
    Note : I need to apply cast to int as column is varchar2, legacy problem.+
    How can I fix this? Am I missing something? In the result of report2 the DB SQL doesn't show the year in where thought it is displayed in the logical sql.
    Let me know if anybody had faced this and have fixed. Or suggetion to make changes to fix this.
    Thannks,
    Ritesh</a>

    Hi Ritesh,
    I think you right about the root cause of your problem. The first request does the group by in the database which returns fewer records to the BI Server for processing. The second request does not do the group by and sends significantly more records back to the BI server forcing it to do the group by. Compound that with the fact that pivot table views are relatively expensive computationally and that explains the difference between the execution times.
    Assuming that the execution time of the first report is satisfactory, I would recommend you try to experiment with a few settings to see if you can get the second report to do the group by in the database.
    Are the two filters identical except for the following conditions?
    cast("Date Dim"."YearCode" as Int) is greater than or equal to @{Start_Year}
    cast("Date Dim"."YearCode" as Int) is greater than or equal to @{End_Year}
    Best regards,
    -Joe

  • SAP MaxDB 7.7.07.16 - performance issue due to IOWait(R) task

    We are running MaxDB 7.7.07.16 unicode in a non SAP environment (is basis for a web application).
    Database Server has 4 Cpu's, 8 Gb RAM, operating system Debian-Linux 6.0.
    We have some performance problems in not regular periods of time.
    The performance problem occurs for a time frame between 3 and 15 minutes and blocks more or less the complete system.
    After a long phase of checking and evaluating possible issues, we think that we are very near to the issue.
    We identified the database tasks
    - TblPrfC  - Prefetch Table Coordinator:
    - PrefPag - Prefetch Pages
    having the current state "IO Wait (R)".
    As long these tasks are in state "IO Wait (R)" the users (at the web application) gets awful slow respond times on their queries.
    On 9th of April 2011 we changed the DB parameters:
    - ReadAheadTableThreshold         old 0 => new 128
    But today we got the same performance problem again.
    If you have any hints or tips, you're welcome!
    Best regards
       Hannes

    Hello Hannes,
    ok brief but hopefully usefull answer to your post:
    - if the database I/O generated by SQL statements alone brings the system to a grinding halt, then your storage system is undersized. How should it be able to handle additional I/O, e.g. for backups if it isn't capable to handle the standard I/O?
    - the prefetching tasks are used to speed up large scan operations. So, the next thing to do here is to find statements that perform table scans and check whether or not these can be tuned to KEY or Index accesses
    - As a workaround, I would propose to increase the value of ReadAheadTableThreshold to, say, 500, so that the prefetching is done only for really large scans.
    regards,
    Lars

  • Performance issue due to localization code in SSRS 2008

    The reports I am working on consist lot of data and all the customers use it frequently.
    Report title and columns are localized by expressions .
    This takes long time for report rendering and exporting to csv. When I test without the localization code it doesn't take that long .
    Can someone help me to optimize the report. SSRS 2008 R2
    Archana

    Hi Archana,
    In Reporting Services, the total time to generate a reporting server report (RDL) can be divided into 3 elements:
    Total time = (TimeDataRetrieval) + (TimeProcessing) + (TimeRendering)
    TimeRendering means the number of milliseconds spent after the Rendering Object Model is exposed to the rendering extension. It includes the Time spent in on-demand expression evaluations (e.g. TextBox.Value, Style.*). So it is make sense that the report
    with localization code takes longer time.
    Besides, we can improve the report performance form other aspects. For example, we can add filter, sorting and aggregation in dataset query, because filter, sort, and aggregation is more efficient on the data source than during report processing. For more
    details about report performance, please refer to the following article:
    http://technet.microsoft.com/en-us/library/bb522806(v=sql.105).aspx
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Performance Issues due to Loading of ADF/JClient View Objects

    Hi,
    I developed a two-tier ADF/JClient application.
    When the ADF/JClient application opens for the first time, there's a big delay
    However opening it subsequently, takes less than half of the time to open the screen.
    I think it might the xml files of different view objects which the framework loads for the first time, and thus takes a lot of time. And after that, the time to open the application reduces.
    We have around 200 view objects in our application. Can this be the reason?
    If yes, then can we load the view objects before ahead, or can we just load them at the very time they are requested ?
    Thanks,
    Makrand Pare

    Hi Makrand,
    Check this out:
    "Limiting Fetching of Business Components Attributes in ADF Swing
    http://www.oracle.com/webapps/online-help/jdeveloper/10.1.3/state/content/navId.4/navSetId._/vtTopicFile.developing_jclient_applications%7Cjui_plimitingfetching%7Ehtml/
    Note: In local mode deployment (the client and Business Components reside in the same VM), the fetching of attribute properties is not supported.
    You can optimize startup time for a Business Components client application and the remotely deployed Business Components by specifying the list of view object attributes that your client uses. If you create a project without the metadata, by coding to the API, you will want to add fetchAttributeProperties() to the bootstrap code of the client forms with a list of only the attributes used by the form. Without this method call, your client form would fetch all control hint properties (including the attributes format and label for example) for all the attributes of the named view objects in the application module, in a single network roundtrip.
    For example, when you do not intend to use all the attributes of the ADF Swing form's bound view object, with the fetchAttributeProperties() method, your ADF Swing form fetches only the information required to layout your forms, while ignoring the attributes you do not require.
    Note: In local mode deployment (the client and Business Components reside in the same VM), the fetching of attribute pro
    Calling fetchAttributeProperties() will prevent property methods such as getFormat() or getLabel() from being called on the Business Components attribute definition whenever the form is created."
    Vlad

Maybe you are looking for