<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Performance problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945301#M1487871</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   DATA lv_count TYPE sytabix.&lt;/P&gt;&lt;P&gt;   CLEAR lv_count. REFRESH t_delete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT t_itab INTO wa_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        IF    wa_itab1-sales_org = wa_itab-sales_org AND&lt;/P&gt;&lt;P&gt;              wa_itab1-cust_pgrp = wa_itab-cust_pgrp AND&lt;/P&gt;&lt;P&gt;              wa_itab1-cust_grp5 = wa_itab-cust_grp5 AND&lt;/P&gt;&lt;P&gt;              wa_itab1-product = wa_itab-product.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          lv_count = lv_count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          IF lv_count &amp;gt; 2.&lt;/P&gt;&lt;P&gt;            DELETE t_itab INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;            APPEND wa_itab TO t_delete.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;        ELSE.&lt;/P&gt;&lt;P&gt;          lv_count = 1.&lt;/P&gt;&lt;P&gt;          wa_itab1 = wa_itab.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for all your suggestions .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Jun 2010 17:50:15 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-06-17T17:50:15Z</dc:date>
    <item>
      <title>Performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945297#M1487867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The logic that the below code tries to accomplish is that it selects the data from a z table and deletes all the data except the most recent two records for every key combination of the sales_grp, cust_pgrp, cust_grp5 and product .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this piece of code which I would like to fine tune because it is running forever (more than 8 hrs in background) becuase the table has 2.5 million records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****************************************************************************************&lt;/P&gt;&lt;P&gt;*Get the data from production/staging tables&lt;/P&gt;&lt;P&gt;  SELECT *&lt;/P&gt;&lt;P&gt;         INTO TABLE t_itab&lt;/P&gt;&lt;P&gt;         FROM ztable&lt;/P&gt;&lt;P&gt;         WHERE interface_id = p_infid AND&lt;/P&gt;&lt;P&gt;               eff_date LE l_date.&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0 AND NOT t_itab[] IS INITIAL.&lt;/P&gt;&lt;P&gt;    SORT  t_itab DESCENDING BY sales_org&lt;/P&gt;&lt;P&gt;                               cust_pgrp&lt;/P&gt;&lt;P&gt;                               cust_grp5&lt;/P&gt;&lt;P&gt;                               product&lt;/P&gt;&lt;P&gt;                               eff_date&lt;/P&gt;&lt;P&gt;                               created_date&lt;/P&gt;&lt;P&gt;                               created_time.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT t_itab INTO wa_itab.&lt;/P&gt;&lt;P&gt;        LOOP AT t_itab INTO wa_itab1 WHERE&lt;/P&gt;&lt;P&gt;                              sales_org = wa_itab-sales_org AND&lt;/P&gt;&lt;P&gt;                              cust_pgrp  = wa_itab-cust_pgrp AND&lt;/P&gt;&lt;P&gt;                              cust_grp5 = wa_itab-cust_grp5 AND&lt;/P&gt;&lt;P&gt;                              product   = wa_itab-product.&lt;/P&gt;&lt;P&gt;         &lt;/P&gt;&lt;P&gt;     CHECK sy-tabix GT 2.  "keep the most recent two records&lt;/P&gt;&lt;P&gt;*Delete invalid entries which no longer needed&lt;/P&gt;&lt;P&gt;          APPEND wa_itab1 TO t_delete.&lt;/P&gt;&lt;P&gt;        ENDLOOP.&lt;/P&gt;&lt;P&gt;        DELETE t_itab WHERE  sales_org = wa_itab-sales_org AND&lt;/P&gt;&lt;P&gt;                             cust_pgrp  = wa_itab-cust_pgrp  AND&lt;/P&gt;&lt;P&gt;                             cust_grp5 = wa_itab-cust_grp5 AND&lt;/P&gt;&lt;P&gt;                             product   = wa_itab-product.&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;****************************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jun 2010 02:01:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945297#M1487867</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-10T02:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945298#M1487868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srinivas ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A&amp;gt; Do as follows :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 &amp;gt; create a secondary index and use that in your select query (by putting the fields in where clause exactly in the same sequence as that of they appear the index you create)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 &amp;gt; Make use of PACKAGE statement in your select query so that it will process eg 1000 records at a time instead of 2.5 million records in one shot. This will definetly improve the performance to greater extend.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 &amp;gt; Please see do you really need all the fields to be fetched from z table , if not then replace select *  with select fields list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4 &amp;gt; Also see if instead of only one condition for date if you can put range of date. Eg  &lt;/P&gt;&lt;P&gt;instead of &lt;/P&gt;&lt;P&gt;eff_date LE l_date , &lt;/P&gt;&lt;P&gt;see if you can have something like below&lt;/P&gt;&lt;P&gt;eff_date IN BETWEEN DATE1 and DATE2 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B &amp;gt; I think your code is doing nothing but than keeping the first 2 records intact and deleting the rest all. If thats true then see the f1 help on delete with where condition and see if you can directly have this accomplished with dete statement on transparent tables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE FROM transperenttable_name &lt;/P&gt;&lt;P&gt;WHERE  zflag &amp;lt;&amp;gt; X .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have one field added  to your transparent table  and while populating records in that table see if you can set it to X for first 2 records in that. and use above logic to delete all except first 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Uma&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: UmaDave on Jun 10, 2010 6:17 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: UmaDave on Jun 10, 2010 6:18 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: UmaDave on Jun 10, 2010 6:22 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jun 2010 04:17:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945298#M1487868</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-10T04:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945299#M1487869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remove the nested loops it is not required. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use control break statement to have the check for the two recent reocrds. I hope thats the case. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No need of separate internal table for t_delete here .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just to give u some idea ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;logic should be like this . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort the entries ..&lt;/P&gt;&lt;P&gt;loop at entries . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check for the combinaiton of &lt;/P&gt;&lt;P&gt;sales_org  cust_pgrp  cust_grp5 entries &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if ok for two entries leave the ztable  "check for  case of one record also &lt;/P&gt;&lt;P&gt;else. &lt;/P&gt;&lt;P&gt;delete the entries there after for the comination of sales_org  cust_pgrp  cust_grp5 entries &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use ctrl break statements at new to check the combination by setting some flag and holding the count of value for two and more than two conditon.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can achieve this with a single loop .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jun 2010 05:10:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945299#M1487869</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-10T05:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945300#M1487870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try using parralel cursor.&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;INTO TABLE t_itab&lt;/P&gt;&lt;P&gt;FROM ztable&lt;/P&gt;&lt;P&gt;WHERE interface_id = p_infid AND&lt;/P&gt;&lt;P&gt;eff_date LE l_date.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0 AND NOT t_itab[] IS INITIAL.&lt;/P&gt;&lt;P&gt;SORT t_itab DESCENDING BY sales_org&lt;/P&gt;&lt;P&gt;cust_pgrp&lt;/P&gt;&lt;P&gt;cust_grp5&lt;/P&gt;&lt;P&gt;product.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT t_itab INTO wa_itab.&lt;/P&gt;&lt;P&gt;READ TABLE t_itab INTO wa_itab1&lt;/P&gt;&lt;P&gt;                           WITH KEY sales_org = wa_itab-sales_org&lt;/P&gt;&lt;P&gt;                                            cust_pgrp = wa_itab-cust_pgrp&lt;/P&gt;&lt;P&gt;                                            cust_grp5 = wa_itab-cust_grp5&lt;/P&gt;&lt;P&gt;                                            product = wa_itab-product&lt;/P&gt;&lt;P&gt;                            BINARY SEARCH.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;l_index = sy-tabix.&lt;/P&gt;&lt;P&gt;LOOP AT t_itab INTO wa_itab1 from l_index.&lt;/P&gt;&lt;P&gt;IF wa_itab1-sales_org NE wa_itab-sales_org&lt;/P&gt;&lt;P&gt;wa_itab1-cust_pgrp NE wa_itab-cust_pgrp&lt;/P&gt;&lt;P&gt;wa_itab1-cust_grp5 NE wa_itab-cust_grp5&lt;/P&gt;&lt;P&gt;wa_itab1-product NE wa_itab-product.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;CHECK sy-tabix GT 2.&lt;/P&gt;&lt;P&gt;wa_itab1-flag = 'X'.&lt;/P&gt;&lt;P&gt;MODIFY t_itab FROM wa_itab1 INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE TABLE t_itab1 where flag = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mrinmoy Dutta on Jun 10, 2010 8:11 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jun 2010 06:04:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945300#M1487870</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-10T06:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945301#M1487871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   DATA lv_count TYPE sytabix.&lt;/P&gt;&lt;P&gt;   CLEAR lv_count. REFRESH t_delete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT t_itab INTO wa_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        IF    wa_itab1-sales_org = wa_itab-sales_org AND&lt;/P&gt;&lt;P&gt;              wa_itab1-cust_pgrp = wa_itab-cust_pgrp AND&lt;/P&gt;&lt;P&gt;              wa_itab1-cust_grp5 = wa_itab-cust_grp5 AND&lt;/P&gt;&lt;P&gt;              wa_itab1-product = wa_itab-product.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          lv_count = lv_count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          IF lv_count &amp;gt; 2.&lt;/P&gt;&lt;P&gt;            DELETE t_itab INDEX sy-tabix.&lt;/P&gt;&lt;P&gt;            APPEND wa_itab TO t_delete.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;        ELSE.&lt;/P&gt;&lt;P&gt;          lv_count = 1.&lt;/P&gt;&lt;P&gt;          wa_itab1 = wa_itab.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for all your suggestions .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jun 2010 17:50:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/6945301#M1487871</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-17T17:50:15Z</dc:date>
    </item>
  </channel>
</rss>

