<?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: ABAP performance vs. T-SQL performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914597#M686055</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;.... ranges is only a good option as long as table 2 is small.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your setting changes, and table 2 has several 1000 entries, then it might not work anymore.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Oct 2007 07:41:14 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-17T07:41:14Z</dc:date>
    <item>
      <title>ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914586#M686044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have done a decent amount of coding in T-SQL but have now moved to SAP-BI development where I am learning ABAP.  I am having some serious concerns to the performance I am seeing through ABAP.  For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code in T-SQL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;delete from TABLE1 where TABLE1.COLUMN1 not in (select TABLE2.COLUMN1 from TABLE2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...I have been told translates to ABAP as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at TABLE1 assigning &amp;lt;TABLE1_FS&amp;gt;.&lt;/P&gt;&lt;P&gt;  read table TABLE2 assigning &amp;lt;TABLE2_FS&amp;gt; with key TABLE2.COLUMN1 =&lt;/P&gt;&lt;P&gt;  &amp;lt;TABLE1_FS&amp;gt;-COLUMN1.&lt;/P&gt;&lt;P&gt;  if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    delete table TABLE1 from &amp;lt;TABLE1_FS&amp;gt;.&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;In this example, TABLE1 has 100,000 records, and TABLE2 has 100 records.  The time it takes in my system for ABAP to complete this statement is around 5 minutes, while the T-SQL it runs it in just seconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something here!&lt;IMG src="??  Can I not get similar performance out of developing in ABAP as I can in T-SQL?  Any advice would be greatly appreciated" /&gt;  (.....for I am going to eventually have to rewrite all of my T-SQL dev to ABAP at my company.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dustin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2007 20:59:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914586#M686044</guid>
      <dc:creator>dustin_self2</dc:creator>
      <dc:date>2007-10-12T20:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914587#M686045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This should help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;read table TABLE2 assigning &amp;lt;TABLE2_FS&amp;gt; with key
  TABLE2.COLUMN1 = &amp;lt;TABLE1_FS&amp;gt;-COLUMN1 
  BINARY SEARCH.                                                "&amp;lt;======
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it's not clear from your post which are database tables and which are internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Rob Burbank&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2007 21:04:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914587#M686045</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-12T21:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914588#M686046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In ABAP, they are all internal tables....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the code, I will try it out to see....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dustin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2007 21:09:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914588#M686046</guid>
      <dc:creator>dustin_self2</dc:creator>
      <dc:date>2007-10-12T21:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914589#M686047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Make sure TABLE2 is sorted by COLUMN1 before doing the read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2007 21:11:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914589#M686047</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-12T21:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914590#M686048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is a sorted table, and I put the "binary search" into the code....but it still takes 5 minutes to run.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dustin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2007 21:42:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914590#M686048</guid>
      <dc:creator>dustin_self2</dc:creator>
      <dc:date>2007-10-12T21:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914591#M686049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dustin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might want to try Hash table on TABLE2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can't  compare T-SQL with internal table processing in ABAP. Database tables in SAP are accessed and manipulated in much the same way as T-SQL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be easier to help if we knew what data is in your tables and how they were loaded as it might be possible to load your TABLE1 from the database with the correct data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the performance you are getting is about right. You won't get performance in seconds no matter how you cut it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Oct 2007 05:23:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914591#M686049</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-13T05:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914592#M686050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if TABLE1 and TABLE2 are two internal table, you can try :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prerequisite : you must add a field named 'FLAG' to table1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA wv_idx LIKE sy-tabix VALUE 1.

SORT                            table1        BY column1.
SORT                            table2        BY column1.
DELETE ADJACENT DUPLICATES FROM table2 COMPARING column1.
LOOP AT table2.
         LOOP AT table1 FROM wv_idx.
                  IF  table1-column1 GT  table2-column1.
                       MOVE sy-tabix TO wv_idx. EXIT.
                  ELSE.
                  IF  table1-column1 EQ  table2-column1.    
                       MOVE 'X'         TO table1-flag." COLUMN1 value exist in TABLE2
                       MODIFY table1 TRANSPORTING flag.               
                  ENDIF. ENDIF.
         ENDLOOP.
ENDLOOP.
DELETE table1 WHERE NOT flag EQ 'X'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Oct 2007 10:04:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914592#M686050</guid>
      <dc:creator>chaouki_akir</dc:creator>
      <dc:date>2007-10-13T10:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914593#M686051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your problem lies elsewhere. There is no way in the world that this should take so long. Would you post your &amp;lt;b&amp;gt;ABAP&amp;lt;/b&amp;gt; code please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Oct 2007 17:35:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914593#M686051</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-14T17:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914594#M686052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dustin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Delete statements within a loop cause performance issues. A better way to write your code would be as follows. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RANGES: r_column1 FOR table2-column1.

IF NOT table2[] IS INITIAL.

  SORT table2 BY column1.

  DELETE ADJACENT DUPLICATES FROM table2 COMPARING column1.

  r_column1-sign   = 'I'.

  r_column1-option = 'EQ'.

  LOOP AT table2.

    r_column1-low = table2-column1.

    APPEND r_column1.

  ENDLOOP.

  DELETE table1 WHERE NOT column1 IN r_column1.

  REFRESH r_column1.

  CLEAR   r_column1.

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if this fixes your issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Oct 2007 22:10:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914594#M686052</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-14T22:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914595#M686053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; In this example, TABLE1 has 100,000 records, and TABLE2 has 100 records. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should be obvious how to solve the problem with that distribution of entries.&lt;/P&gt;&lt;P&gt;MOVE the 100 lines from table1 into a new table!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What type is table1, if sorted then o.k., otherwise if memory is no problem (if table1 is not too wide) then move table1 into hash1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT table2 INTO wa2.&lt;/P&gt;&lt;P&gt;   READ TABLE table1&lt;/P&gt;&lt;P&gt;             INTO wa1&lt;/P&gt;&lt;P&gt;             WITH TABLE KEY coulmn1 = wa2-column1.&lt;/P&gt;&lt;P&gt;   IF (sy-subrc eq = 0 ).&lt;/P&gt;&lt;P&gt;     APPEND wa1  to new_table1.&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;REFRESH table1.&lt;/P&gt;&lt;P&gt;table1[] = new_table1[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 11:40:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914595#M686053</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-15T11:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914596#M686054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!  The concept of range tables worked great!  It ran that delete statement in just seconds.  I really appreciate your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dustin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2007 14:29:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914596#M686054</guid>
      <dc:creator>dustin_self2</dc:creator>
      <dc:date>2007-10-15T14:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP performance vs. T-SQL performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914597#M686055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;.... ranges is only a good option as long as table 2 is small.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your setting changes, and table 2 has several 1000 entries, then it might not work anymore.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 07:41:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-performance-vs-t-sql-performance/m-p/2914597#M686055</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-17T07:41:14Z</dc:date>
    </item>
  </channel>
</rss>

