<?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 considerations for DB updates in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299123#M789638</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;plz consider  Follwing points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Transaction SE30 (ABAP Runtime Analysis) must be checked to measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE. Remember not always the data element name matches with the table field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal Table is defined with "TYPE STANDARD TABLE OF" &amp;amp; Work-Areas is used instead of header lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No SELECT * is used&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SELECT statement, only the required fields are selected in the same order as they reside on the database table/structure/view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For selecting single row from a database table, "SELECT UP to 1 Rows" is used. "Select Single" is used only when full primary key combination is known.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use "SELECT INTO TABLE" rather than "SELECT INTO CORRESPONDING FIELDS OF TABLE".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always specify as many primary keys as possible in WHERE clause to make the Select efficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always select into an internal table, except when the table will be very large (i.e., when the internal table will be greater than 500,000 records). Use "Up to N Rows" when the number of records needed is known.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested Select is not used instead "Inner Join" and/or "For all Entries" is used. "For all Entries" is to be used over "Loop at ITAB / Select / ENDLOOP" (FOR ALL ENTRIES retrieves a unique result set so ensure you retrieve the full key from the database) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition else use " FOR ALL ENTRIES" select statement.&lt;/P&gt;&lt;P&gt;Usage of JOIN is limited to a maximum of 2 i.e. not more than 3 database tables are joined at one time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all entries from the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Delete adjacent duplicate entries from internal table before selection from database table using " FOR ALL ENTRIES" statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For copying internal tables use '=' operator instead of Looping &amp;amp; Appending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT inside a LOOP is not used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of sorting is invalid the BINARY SEARCH will never work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For large internal tables where only some rows are to be processed, use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. Use CHECK or IF&amp;#133;EXIT&amp;#133;ENDIF as appropriate to exit from the loop .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2 ASCENDING)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE or SORT is not used on a hashed table since it increases memory consumption.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorted table is used for range accesses involving table key or index accesses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fields specified in the WHERE condition with the critical operators NOT and &amp;lt;&amp;gt; (negative SQL statements) cannot be used for a search using database indexes. Whenever possible formulate SQL statements positively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When coding IF or CASE, testing conditions are nested so that the most frequently true conditions are processed first. Also CASE is used instead of IF when testing multiple fields "equal to" something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB INTO WORKAREA WHERE K = 'XXX' should be used instead of LOOP AT ITAB INTO WORKAREA / CHECK ITAB-K = 'XXX'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the APPEND statement inside a loop, the work area that has been appended is cleared.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do not delete the records of internal table inside the Loop &amp;#150; End loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do not use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB WHERE EQUNR = '00001011'. &lt;/P&gt;&lt;P&gt;DELETE ITAB.&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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ITAB WHERE EQUNR = '00001011'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 02 Feb 2008 06:45:42 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-02T06:45:42Z</dc:date>
    <item>
      <title>Performance considerations for DB updates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299121#M789636</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;What are the Performance considerations for DB updates&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Suneela.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 06:27:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299121#M789636</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T06:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Performance considerations for DB updates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299122#M789637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi suneela,&lt;/P&gt;&lt;P&gt;try this linkit vl give some points about performance considerations .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.erpgenie.com/abaptips/content/view/252/67/" target="test_blank"&gt;http://www.erpgenie.com/abaptips/content/view/252/67/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 06:40:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299122#M789637</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T06:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Performance considerations for DB updates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299123#M789638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;plz consider  Follwing points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Transaction SE30 (ABAP Runtime Analysis) must be checked to measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE. Remember not always the data element name matches with the table field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal Table is defined with "TYPE STANDARD TABLE OF" &amp;amp; Work-Areas is used instead of header lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No SELECT * is used&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SELECT statement, only the required fields are selected in the same order as they reside on the database table/structure/view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For selecting single row from a database table, "SELECT UP to 1 Rows" is used. "Select Single" is used only when full primary key combination is known.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use "SELECT INTO TABLE" rather than "SELECT INTO CORRESPONDING FIELDS OF TABLE".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always specify as many primary keys as possible in WHERE clause to make the Select efficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always select into an internal table, except when the table will be very large (i.e., when the internal table will be greater than 500,000 records). Use "Up to N Rows" when the number of records needed is known.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested Select is not used instead "Inner Join" and/or "For all Entries" is used. "For all Entries" is to be used over "Loop at ITAB / Select / ENDLOOP" (FOR ALL ENTRIES retrieves a unique result set so ensure you retrieve the full key from the database) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition else use " FOR ALL ENTRIES" select statement.&lt;/P&gt;&lt;P&gt;Usage of JOIN is limited to a maximum of 2 i.e. not more than 3 database tables are joined at one time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all entries from the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Delete adjacent duplicate entries from internal table before selection from database table using " FOR ALL ENTRIES" statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For copying internal tables use '=' operator instead of Looping &amp;amp; Appending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT inside a LOOP is not used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of sorting is invalid the BINARY SEARCH will never work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For large internal tables where only some rows are to be processed, use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. Use CHECK or IF&amp;#133;EXIT&amp;#133;ENDIF as appropriate to exit from the loop .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2 ASCENDING)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE or SORT is not used on a hashed table since it increases memory consumption.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorted table is used for range accesses involving table key or index accesses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fields specified in the WHERE condition with the critical operators NOT and &amp;lt;&amp;gt; (negative SQL statements) cannot be used for a search using database indexes. Whenever possible formulate SQL statements positively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When coding IF or CASE, testing conditions are nested so that the most frequently true conditions are processed first. Also CASE is used instead of IF when testing multiple fields "equal to" something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB INTO WORKAREA WHERE K = 'XXX' should be used instead of LOOP AT ITAB INTO WORKAREA / CHECK ITAB-K = 'XXX'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After the APPEND statement inside a loop, the work area that has been appended is cleared.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do not delete the records of internal table inside the Loop &amp;#150; End loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do not use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB WHERE EQUNR = '00001011'. &lt;/P&gt;&lt;P&gt;DELETE ITAB.&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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ITAB WHERE EQUNR = '00001011'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 06:45:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299123#M789638</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T06:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Performance considerations for DB updates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299124#M789639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;better u should go thru the following link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://erpgenie.com/abaptips/content/view/235/67/" target="test_blank"&gt;http://erpgenie.com/abaptips/content/view/235/67/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u ll get all the deatls reg do's and donts along with performance factors .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 06:53:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299124#M789639</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T06:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Performance considerations for DB updates</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299125#M789640</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;&lt;/P&gt;&lt;P&gt;Array updates&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;All Database manipulations in SAP (UPDATE, INSERT, DELETE) can be executed one record at a time or through an 'Array' operation.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;    Example:&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;    No good    &lt;/P&gt;&lt;P&gt;    LOOP AT T_MAT.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Assign value to material group MARA-MATKL&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      &amp;#133;&amp;#133;&lt;/P&gt;&lt;P&gt;      UPDATE MARA SET MATKL = T_MAT-MATKL.&lt;/P&gt;&lt;P&gt;             WHERE MATNR = T_MAT-MATNR.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   GOOD&lt;/P&gt;&lt;P&gt;    LOOP AT T_MAT.    &lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Assign value to material group MARA-MATKL&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      &amp;#133;&amp;#133;  &lt;/P&gt;&lt;P&gt;    ENDLOOP&lt;/P&gt;&lt;P&gt;    UPDATE MARA FROM TABLE T_MAT.&lt;/P&gt;&lt;P&gt;       &lt;/P&gt;&lt;P&gt;    After the execution of the array update, the following system fields are populated:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC - Contains 0 if all updates were successfully executed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-DBCNT -Contains the number of successfully updated records&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Restrictions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Array update function can't be combined with UPDATE SET&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;   Recommendation:&lt;/P&gt;&lt;P&gt;     &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a large number of fields are changed in multiple records ? Array update&lt;/P&gt;&lt;P&gt;If a small number of fields are changed in one record ? Update set&lt;/P&gt;&lt;P&gt;If a small number of fields are changed in multiple records &lt;/P&gt;&lt;P&gt;        -&amp;gt; Define a modifiable view using the key fields and the fields which are to be changed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Updating Key fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Key fields can be updated for transparent tables just like any other table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exception:&lt;/P&gt;&lt;P&gt;If synchronous match codes exist for the table, the key field update will be unsuccessful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reward Points if found helpfull..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cheers,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Chandra Sekhar.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 09:12:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-considerations-for-db-updates/m-p/3299125#M789640</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T09:12:10Z</dc:date>
    </item>
  </channel>
</rss>

