<?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 issue in select and loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700743#M1769102</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://zevolving.com/2013/02/abap-internal-table-performance-for-standard-sorted-and-hashed-table/"&gt;This&lt;/A&gt; is a very compact and recent comparison between different tables types. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;People are afraid of trying. It's the bad and old "why change if everything is working?" (working slower in this case &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1735/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt; ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Sep 2013 11:38:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-09-05T11:38:52Z</dc:date>
    <item>
      <title>Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700735#M1769094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to adjust the performance of my code, the execution like it is now takes very long to run. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "bw_table"&amp;nbsp; contains around 7 fields and 40'000 posts. &lt;/P&gt;&lt;P&gt;And the "result_package" contains 60 fields and appr 2'000'000 posts &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any better ways to adjust this code below? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM bw_table&lt;/P&gt;&lt;P&gt;INTO TABLE it_bw_table&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN Result_package&lt;/P&gt;&lt;P&gt;WHERE cond1 = cond2 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT Result_package ASSIGNING &amp;lt;result&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_bw_table INTO ls_bw_table &lt;/P&gt;&lt;P&gt;WHERE cond1 = &amp;lt;result&amp;gt;-cond1&lt;/P&gt;&lt;P&gt;AND cond2 = &amp;lt;result&amp;gt;-cond2&lt;/P&gt;&lt;P&gt;AND cond3 = &amp;lt;result&amp;gt;-cond3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF statement&lt;/P&gt;&lt;P&gt;ELSEIF statement&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;ENDLOOP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 15:31:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700735#M1769094</guid>
      <dc:creator>former_member300655</dc:creator>
      <dc:date>2013-09-04T15:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700736#M1769095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 17:17:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700736#M1769095</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-04T17:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700737#M1769096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i) do you need all the fields of bw_table? if not, then fetch selected fields only to avoid '*' from select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ii) Avoid nested loop as well. one way to do it....consolidate data from both internal tables into another table and then use Loop with Read to this table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 17:20:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700737#M1769096</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-04T17:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700738#M1769097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LOOP AT Result_package ASSIGNING &amp;lt;result&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_bw_table BY cond1 cond2 cond3.&lt;/P&gt;&lt;P&gt;READ TABLE it_bw_table WITH KEY cond1 = &amp;lt;result&amp;gt;-cond1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cond2 = &amp;lt;result&amp;gt;-cond2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cond3 = &amp;lt;result&amp;gt;-cond3 BINARY SEARCH TRANSPORTING NO FIELDS.&lt;/P&gt;&lt;P&gt;IF sy-subrc IS INITIAL.&lt;/P&gt;&lt;P&gt;lv_tabix = sy-tabix.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;CONTINUE.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_bw_table INTO ls_bw_table FROM lv_tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF ls_bw_table-cond1 NE &amp;lt;result&amp;gt;-cond1&lt;/P&gt;&lt;P&gt;OR ls_bw_table-cond2 NE &amp;lt;result&amp;gt;-cond2&lt;/P&gt;&lt;P&gt;OR ls_bw_table-cond3 NE &amp;lt;result&amp;gt;-cond3.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF statement&lt;/P&gt;&lt;P&gt;ELSEIF statement&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;ENDLOOP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 20:05:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700738#M1769097</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-04T20:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700739#M1769098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; No doubt you will get a LOT of replies to this question, but let me ask you: have you done a simple performance analysis, to see if the main issue is in the SELECT, the nested LOOP, or in the STATEMENT part of your code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd advise you to identify where the problem is first, then focus on that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the problem is in the SELECT statement, I would just remove the FOR ALL ENTRIES line.&lt;/P&gt;&lt;P&gt;It's counter-productive to use FOR ALL ENTRIES if the driver table is large (especially if the DB table is small)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 02:04:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700739#M1769098</guid>
      <dc:creator>paul_bakker2</dc:creator>
      <dc:date>2013-09-05T02:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700740#M1769099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If possible use a JOIN between bw_table and result_package table.&lt;/P&gt;&lt;P&gt;If it's not possible, assure that the values of the fields in FAE-table used in WHERE-clause of SELECT are unique.&lt;/P&gt;&lt;P&gt;Use a SORTED TABLE for it_bw_table to optimize access in LOOP with WHERE-clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;DATA it_bw_table type SORTED TABLE of ltype_bw_table&lt;BR /&gt; with non-unique key cond1 cond2 cond3.&lt;/P&gt;&lt;P&gt;LOOP AT Result_package ASSIGNING &amp;lt;result&amp;gt;.&lt;BR /&gt; COLLECT &amp;lt;result&amp;gt;-condx into condx_table.&amp;nbsp;&amp;nbsp; "assumption: &amp;lt;result&amp;gt;-condx is non-numeric &lt;BR /&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;SELECT * FROM bw_table&lt;BR /&gt;INTO TABLE it_bw_table&lt;BR /&gt;FOR ALL ENTRIES IN condx_table&lt;BR /&gt;WHERE cond1 = condx_table-table_line. &lt;/P&gt;&lt;P&gt;LOOP AT Result_package ASSIGNING &amp;lt;result&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOOP AT it_bw_table INTO ls_bw_table &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE cond1 = &amp;lt;result&amp;gt;-cond1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND cond2 = &amp;lt;result&amp;gt;-cond2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND cond3 = &amp;lt;result&amp;gt;-cond3&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF statement&lt;/P&gt;&lt;P&gt;&amp;nbsp; ELSEIF statement&lt;/P&gt;&lt;P&gt;&amp;nbsp; ENDIF&lt;/P&gt;&lt;P&gt;&amp;nbsp; ENDLOOP&lt;/P&gt;&lt;P&gt;ENDLOOP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards, Randolf&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 06:50:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700740#M1769099</guid>
      <dc:creator>former_member184455</dc:creator>
      <dc:date>2013-09-05T06:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700741#M1769100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's amazing how many people are still using BINARY SEARCH. When were sorted tables introduced? Only 15 years ago...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 08:33:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700741#M1769100</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2013-09-05T08:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700742#M1769101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't use BINARY SEARCH. SORTED/HASHED tables have been around for 15 years...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 08:33:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700742#M1769101</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2013-09-05T08:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700743#M1769102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://zevolving.com/2013/02/abap-internal-table-performance-for-standard-sorted-and-hashed-table/"&gt;This&lt;/A&gt; is a very compact and recent comparison between different tables types. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;People are afraid of trying. It's the bad and old "why change if everything is working?" (working slower in this case &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1735/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt; ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 11:38:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700743#M1769102</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-05T11:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700744#M1769103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The performance issue which you are facing is mostly due to the nested loop within the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try using &lt;STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;Parallel &lt;/SPAN&gt;&lt;SPAN class="L0S52" style="font-size: 10pt;"&gt;cursor &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="L0S52" style="font-size: 10pt;"&gt;&lt;STRONG&gt;method &lt;/STRONG&gt;instead, which I think might improve your program's performance.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Sep 2013 14:37:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700744#M1769103</guid>
      <dc:creator>mayur_priyan</dc:creator>
      <dc:date>2013-09-13T14:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Performance issue in select and loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700745#M1769104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Make sure that internal table RSULT_PACKAGE is sorted by cond1, cond2, cond3.&lt;/LI&gt;&lt;LI&gt;Only one single LOOP at internal table RESULT_PACKAGE.&lt;/LI&gt;&lt;LI&gt;In this LOOP only on change of conditions SELECT matching entries from BW_TABLE into internal table.&lt;/LI&gt;&lt;LI&gt;Make sure that access to table BW_TABLE has a fitting primary or secondary index. &lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Sep 2013 06:12:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issue-in-select-and-loop/m-p/9700745#M1769104</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-09-17T06:12:09Z</dc:date>
    </item>
  </channel>
</rss>

