<?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 OPEN SQL performance question in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259780#M147241</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm going to read and process data in an interface coded in ABAP and OPEN SQL. To improve efficiency and reliability I'm processing the data in packets of a fixed size of rows - reading rows up to a predetermined numer into an internal table which then is processed and then finaly written back to database followed by "commit work". Then the process will continue with reading the next fixed number of rows, process them, and so on ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The general question is, which is the most efficient way to implement this scenario?&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;I think of two basic approaches:&lt;/P&gt;&lt;P&gt;1.1) Loop over results from a cursor using FETCH NEXT CURSOR inside a LOOP appending the lines to the internal table. &lt;/P&gt;&lt;P&gt;2.1) Execute SELECT ... INTO TABLE &amp;lt;itab&amp;gt; FROM &amp;lt;table&amp;gt; UP TO &amp;lt;data packet size&amp;gt; ROWS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My assumtion is that approach 2 would be the more effecient, is that correct? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The processed data will be written back to the database in one single statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.2) INSERT &amp;lt;table&amp;gt; FROM TABLE &amp;lt;itab&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which I assume is more efficient than doing the same using multiple inserts within a loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Apr 2006 20:04:12 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-04-24T20:04:12Z</dc:date>
    <item>
      <title>OPEN SQL performance question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259780#M147241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm going to read and process data in an interface coded in ABAP and OPEN SQL. To improve efficiency and reliability I'm processing the data in packets of a fixed size of rows - reading rows up to a predetermined numer into an internal table which then is processed and then finaly written back to database followed by "commit work". Then the process will continue with reading the next fixed number of rows, process them, and so on ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The general question is, which is the most efficient way to implement this scenario?&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;I think of two basic approaches:&lt;/P&gt;&lt;P&gt;1.1) Loop over results from a cursor using FETCH NEXT CURSOR inside a LOOP appending the lines to the internal table. &lt;/P&gt;&lt;P&gt;2.1) Execute SELECT ... INTO TABLE &amp;lt;itab&amp;gt; FROM &amp;lt;table&amp;gt; UP TO &amp;lt;data packet size&amp;gt; ROWS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My assumtion is that approach 2 would be the more effecient, is that correct? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The processed data will be written back to the database in one single statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.2) INSERT &amp;lt;table&amp;gt; FROM TABLE &amp;lt;itab&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which I assume is more efficient than doing the same using multiple inserts within a loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2006 20:04:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259780#M147241</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-24T20:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN SQL performance question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259781#M147242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Christian  ,&lt;/P&gt;&lt;P&gt;2nd one is more efficient.&lt;/P&gt;&lt;P&gt;Lets understand this...&lt;/P&gt;&lt;P&gt;in 2nd SELECT you make single call to database. This saves time and load on database..&lt;/P&gt;&lt;P&gt;Same applies for INSERT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should always try to reduce making unneccessary journeys to DB as it results in loss of time and puts load on DB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tanveer.&lt;/P&gt;&lt;P&gt;Please mark helpful answers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2006 20:13:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259781#M147242</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-24T20:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN SQL performance question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259782#M147243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In native SQL you can also use the packet options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  &amp;lt;Fields name&amp;gt;      appending corresponding fields of table &amp;lt;Internal table&amp;gt;&lt;/P&gt;&lt;P&gt;            &amp;lt;b&amp;gt;package size 20000&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;            FROM &amp;lt;Database table name&amp;gt;&lt;/P&gt;&lt;P&gt;            WHERE &amp;lt;Condition&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;By using this the system will fetch the records from database table in packets [20000 records per package]&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Aman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2006 20:16:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259782#M147243</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-24T20:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN SQL performance question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259783#M147244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Inserting from an internal table is more efficient, but you have to make sure that the table is small enough so that the program doesn't exceed the rollback area(s).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2006 20:22:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259783#M147244</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-24T20:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN SQL performance question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259784#M147245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aman,&lt;/P&gt;&lt;P&gt;I think using "SELECT.. ENDSELECT" and even "APPENDING CORRESPONDING FIELDS" have high performance constraints. &lt;/P&gt;&lt;P&gt;I would suggest the second option by Christian.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tanveer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2006 20:25:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259784#M147245</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-24T20:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN SQL performance question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259785#M147246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what would you finally recommend? To use "package size &amp;lt;n&amp;gt;" or "up to &amp;lt;n&amp;gt; rows" to restrict the number of read records in each processing step?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;/ C&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2006 20:35:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259785#M147246</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-24T20:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN SQL performance question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259786#M147247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you use up to &amp;lt;n&amp;gt; rows, you will always get the same rows of data. Package size &amp;lt;n&amp;gt; will get you the next group of records each time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2006 20:43:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259786#M147247</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-24T20:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: OPEN SQL performance question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259787#M147248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But what I would do would be to select all of the entries into an internal table at one time. Then move them in packets of say 5,000 records to a second table and do the insert from the second table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2006 20:48:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-sql-performance-question/m-p/1259787#M147248</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-24T20:48:14Z</dc:date>
    </item>
  </channel>
</rss>

