<?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: Optimisation question, internal table vs multiple DB calls in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142111#M1513611</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is your main issue, one execution of ZCL_DBSA_REPORTS=&amp;gt;GET_UNIV_TRANS_REP requires 700sec&lt;/P&gt;&lt;P&gt;17000 exections of the LOAN_FLOWS_SUPPLY require the rest, the 360sec &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would assume that your internal table handling is suboptimal. Either show the full code of ZCL_DBSA_REPORTS=&amp;gt;GET_UNIV_TRANS_REP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But to make it easier, run the ABAP Trace again and switch on internal table tracing, that will break down the 700 sec.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Later yu should provide the SQL trace for the testcase, maybe it is possible to optimize the VDBEKI fetch with a self written buffer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Aug 2010 09:22:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-08-30T09:22:07Z</dc:date>
    <item>
      <title>Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142105#M1513605</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;I have to optimise a program. The program is a loans report for bank. The main tables used are VDARL, VDBEKI and VDBEPI. VDBEKI(loans master) has about 16000records, VDBEKI and VDBEPI(flows\cash flows) have about 1000 000 records each. Currently the program loops through each loan(16 000 loans) and then calls a standard Function module LOAN_FLOWS_SUPPLY(retrieves cash flows from VDBEKI and VDBEPI) . LOAN_FLOWS_SUPPLY has the following join in it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    SELECT * INTO TABLE wrk_t_beki_bepi
      FROM (    vdbeki AS vdbeki INNER JOIN vdbepi AS vdbepi
            ON  vdbeki~mandt    = vdbepi~mandt
            AND vdbeki~bukrs    = vdbepi~bukrs
            AND vdbeki~rbelkpfd = vdbepi~rbelkpfd )
      WHERE      vdbeki~bukrs    EQ  i_bukrs
        AND      vdbeki~ranl     EQ  i_ranl
        AND      vdbeki~sstorno  IN wrk_sstorno
        AND      vdbepi~dvalut   LE i_dvalut_until
        AND      vdbepi~dfaell   LE i_dfaell_until
        AND      vdbepi~ddispo   LE i_ddispo_until
        AND      vdbepi~dfaell   GE i_due_date_from
        AND      vdbepi~dfaell   LE i_due_date_until
        AND (    vdbeki~s_compr  IN wrk_compr      "       NOTE 580603
              OR vdbeki~s_compr  IS NULL        ). "   &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The real problem is that its doing this for every loan, so there is a lot of back and forth between the DB server and the Application server. The other alternative is for me to create an internal table for VDBEKI, but since VDBEKI has about a million records, this will require a lot of memory?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What should I do? should I create an internal table for this or find another alternative for this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Aug 2010 10:51:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142105#M1513605</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-27T10:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142106#M1513606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the other option is to rewrite LOAN_FLOWS_SUPPLY with logic only relevant to our requirements&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Aug 2010 10:56:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142106#M1513606</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-27T10:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142107#M1513607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This function is also used in many SAP standard programs, did you check for related SAP notes dealing with performance problems in this area?&lt;/P&gt;&lt;P&gt;This would be my first investigation, if there is nothing, then you could open a call with SAP, however if I understand correctly the calling program is your own development, so you will probably be turned down.&lt;/P&gt;&lt;P&gt;After that we can check additional options &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Aug 2010 11:09:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142107#M1513607</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2010-08-27T11:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142108#M1513608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;no, I have not checked for any sap notes on it. The calling program was developed by someone else, I have been tasked to optimize it. After looking at the program I don't see much that I can optimise. The makority of the time is consumed by this function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the main logic where it loops through an internal table for vdarl&lt;/P&gt;&lt;P&gt;&lt;A href="http://codeviewer.org/view/code:1117" target="test_blank"&gt;http://codeviewer.org/view/code:1117&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is a breakdown of the runtime&lt;/P&gt;&lt;P&gt;&lt;A href="http://farm5.static.flickr.com/4099/4931329631_163d4fa70c_b.jpg" target="test_blank"&gt;http://farm5.static.flickr.com/4099/4931329631_163d4fa70c_b.jpg&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Aug 2010 11:29:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142108#M1513608</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-27T11:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142109#M1513609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you check ZCL_DBSA_REPORTS=&amp;gt;GET_UNIV_TRANS_REP ?&lt;/P&gt;&lt;P&gt;This takes 58.4% net time, and you should start to optimize...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 08:20:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142109#M1513609</guid>
      <dc:creator>former_member131774</dc:creator>
      <dc:date>2010-08-30T08:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142110#M1513610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I can't see much room for improvement in "ZCL_DBSA_REPORTS=&amp;gt;GET_UNIV_TRANS_REP ", that section of the code makes use of internal tables where possible and transfers between DB and APP server are kept to a minimum. So far, I have eliminated a few unnecessary layers &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I really need advice on is, is it better to create internal tables for VDBEKI and VDBEPI(cash flows) each having up to a million records or should I stick to using LOAN_FLOWS_SUPPLY which retrieves cash flow on a per loan basis but incurs the cost of having to fetch flows per loan from the DB. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which is more expensive in terms of time: #1 loading 2 massive internal tables and using READ or #2fetching flows for each loan by going to the DB for each and selecting via a join from VDBEKI &amp;amp; VDBEPI?? #3 going the middle route and creating an internal table for VDBEKI and selecting VDBEPI flows from DB using a select * for all entries in IT_VDBEKI for that specific loan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 09:03:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142110#M1513610</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-30T09:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142111#M1513611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is your main issue, one execution of ZCL_DBSA_REPORTS=&amp;gt;GET_UNIV_TRANS_REP requires 700sec&lt;/P&gt;&lt;P&gt;17000 exections of the LOAN_FLOWS_SUPPLY require the rest, the 360sec &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would assume that your internal table handling is suboptimal. Either show the full code of ZCL_DBSA_REPORTS=&amp;gt;GET_UNIV_TRANS_REP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But to make it easier, run the ABAP Trace again and switch on internal table tracing, that will break down the 700 sec.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Later yu should provide the SQL trace for the testcase, maybe it is possible to optimize the VDBEKI fetch with a self written buffer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 09:22:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142111#M1513611</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-30T09:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142112#M1513612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Which is more expensive in terms of time: #1 loading 2 massive internal tables and using READ or #2fetching flows for each loan by going to the DB for each and selecting via a join from VDBEKI &amp;amp; VDBEPI?? #3 going the middle route and creating an internal table for VDBEKI and selecting VDBEPI flows from DB using a select * for all entries in IT_VDBEKI for that specific loan.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Usually you should go for #3, but it depends (it depends, for example, on many entries will be in your internal table for VDBEKI, as compared to the total number of rows in the db). You will end up with big internal tables, so you then &lt;STRONG&gt;must make sure&lt;/STRONG&gt; you use SORTED TABLE (probably for VDBEPI, I haven't checked all your code); that is crucial, otherwise you will end up with worse performance.&lt;/P&gt;&lt;P&gt;But why don't you try yourself and post your results?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, Vincent Zhao is right: from your SE30, the LOAN_FLOWS_SUPPLY is "only" 25% (gross), while GET_UNIV_TRANS_REP has 58% net. Sticking with the "but my problem really is..." is a common mistake; if you ask questions in the forum you have to be prepared to accept the answers and at least consider what people are suggesting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calling a method in itself is not heavy, so the 58% net time means that it is taking time in something else that is not shown in the analysis; usually that is internal table operations, since they are not checked in the default SE30 variant (if that is true, you probably have a big percentage for ABAP in the first screen of the SE30 analysis). Expensive internal table operations usually mean READs or LOOPs over big non-sorted/hashed tables. If I were you I would run SE30 with a variant that includes Internal tables operations, and then check where your biggest net time is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Rui Dantas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 09:25:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142112#M1513612</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-08-30T09:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142113#M1513613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried  , here is the code for  zcl_dbsa_reports=&amp;gt;get_univ_trans_rep method&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://codeviewer.org/view/code:119a" target="test_blank"&gt;http://codeviewer.org/view/code:119a&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is trace with internal table tracing switched on&lt;/P&gt;&lt;P&gt;&lt;A href="http://farm5.static.flickr.com/4149/4963227226_3ecb66939e_b_d.jpg" target="test_blank"&gt;http://farm5.static.flickr.com/4149/4963227226_3ecb66939e_b_d.jpg&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Sep 2010 08:15:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142113#M1513613</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-06T08:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142114#M1513614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should check the lines with more net time.&lt;/P&gt;&lt;P&gt;In the runtime analysis, if you select "Read Table IT_854" and press "Display Source Code (CTRL+F7)" what line does it go to?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Sep 2010 09:33:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142114#M1513614</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-09-06T09:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142115#M1513615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it takes me to the first line in the code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*   loan dates
    read table lt_zcml_loan_dates into ls_zcml_loan_dates
    with key bukrs = ls_output-bukrs
             ranl = ls_output-ranl
             dateno = gc_51.
    if sy-subrc eq 0.
      ls_output-actdate_51 = ls_zcml_loan_dates-actdate.
      ls_output-repyear_51 = ls_zcml_loan_dates-repyear.
      ls_output-repper_51  = ls_zcml_loan_dates-repper.
    endif.
    read table lt_zcml_loan_dates into ls_zcml_loan_dates with key dateno = gc_53.
    if sy-subrc eq 0.
      ls_output-actdate_53 = ls_zcml_loan_dates-actdate.
      ls_output-repyear_53 = ls_zcml_loan_dates-repyear.
      ls_output-repper_53  = ls_zcml_loan_dates-repper.
    endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Sep 2010 09:42:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142115#M1513615</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-06T09:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142116#M1513616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bijo, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then that means the READ to lt_zcml_loan_dates alone is taking 35% of the execution time. You have two of those reads, though the runtime analysis only shows one (probably because you selected FULL aggregation).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the second read do you really want to read only with dateno, or should it use also bukrs and ranl ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, change it to a SORTED TABLE by dateno, bukrs, ranl, and you should be ok. Then measure again to confirm it improved, and to check where you should attack next.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Sep 2010 10:34:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142116#M1513616</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-09-06T10:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142117#M1513617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;please check in all your new developments that you use suitable internal tables, either sorted or hashed for every table which can have more than 50 records:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Measurements on internal tables: Reads and Loops:&lt;/P&gt;&lt;P&gt;/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Sep 2010 10:53:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142117#M1513617</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-06T10:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142118#M1513618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Changing the table to a sorted table has had a substantial effect, I changed the internal table lt_zcml_loan_dates to a sorted table with unique key for  bukrs, ranl and dateno. I created a second table  also a sorted table but with non-unique key for dateno (for the second read statement). As you can see from the before and after images using the same set of data, the table read time has substantially decreased. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One more thing,  the most costly sql statement in this application is this (within the LOAN_FLOWS_SUPPLY function module)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * INTO TABLE wrk_t_beki_bepi
      FROM (    vdbeki AS vdbeki INNER JOIN vdbepi AS vdbepi
            ON  vdbeki~mandt    = vdbepi~mandt
            AND vdbeki~bukrs    = vdbepi~bukrs
            AND vdbeki~rbelkpfd = vdbepi~rbelkpfd )
      WHERE      vdbeki~bukrs    EQ  i_bukrs
        AND      vdbeki~ranl     EQ  i_ranl
        AND      vdbeki~sstorno  IN wrk_sstorno
        AND      vdbepi~dvalut   LE i_dvalut_until
        AND      vdbepi~dfaell   LE i_dfaell_until
        AND      vdbepi~ddispo   LE i_ddispo_until
        AND      vdbepi~dfaell   GE i_due_date_from
        AND      vdbepi~dfaell   LE i_due_date_until
        AND (    vdbeki~s_compr  IN wrk_compr      "       NOTE 580603
              OR vdbeki~s_compr  IS NULL        ). "  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;will creating indexes for vdbeki and vdbepi accomadating the fields in the select above make a substantial effect to the run time of this program? (sstorno, s_compr are not key fields of vdbeki . dvalut, dfaell, ddispo are not key fields of vdbepi)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for your advice so far, you have been a great help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;before &lt;/P&gt;&lt;P&gt;&lt;A href="http://farm5.static.flickr.com/4127/4990770194_469d01a62f_b.jpg" target="test_blank"&gt;http://farm5.static.flickr.com/4127/4990770194_469d01a62f_b.jpg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after&lt;/P&gt;&lt;P&gt;&lt;A href="http://farm5.static.flickr.com/4089/4990165823_a1ac695d6e_b.jpg" target="test_blank"&gt;http://farm5.static.flickr.com/4089/4990165823_a1ac695d6e_b.jpg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Bijo Samuel on Sep 14, 2010 7:50 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Sep 2010 17:38:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142118#M1513618</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-14T17:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142119#M1513619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bijo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my system those tables have no entries so I can't really check, but as you said in the very beginning it seems that the access is good but is done lots of times. You should make a trace and check it in ST05, but I suppose that the query is using index VDBEKI~4 (by BUKRS and RANL). If you check in SE16, how many entries are there on average for a given BUKRS and RANL? If it is a small number then your access is already good, and you can't improve much by additional indexes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution would be to read the data directly with FOR ALL ENTRIES (or maybe directly with a join with VDARL), instead of making a loop and calling LOAN_FLOWS_SUPPLY. This, however, means you have to replicate the logic inside the standard function; if all you want from the fuction is O_VDBEKI and O_VDBEPI then that should be pretty straightforward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Rui&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Sep 2010 09:25:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142119#M1513619</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-09-15T09:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142120#M1513620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more thing: you might also want to check if these two related OSS notes apply to you. &lt;/P&gt;&lt;P&gt;They are a modification to the standard, so consider if you really want to do it. They promise a 30% improvement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note 947139 - Poor performance when system reads documents&lt;/P&gt;&lt;P&gt;Note 969396 - Convert table VDBEPI to Oracle Index-Organized Table (IOT)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rui Dantas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Sep 2010 09:34:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142120#M1513620</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-09-15T09:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142121#M1513621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bijo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to help you for the select we would need to have all the execution details from ST04 / ST05.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you try the mentioned notes from Rui, please let us know the results. I heard from different people applying the suggestions with great and not so great sucess so i am interested in other experiences.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Sep 2010 10:03:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142121#M1513621</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-09-15T10:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142122#M1513622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui, Hermann&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the delayed reply. The average number of records in vdbeki and vdbepi for a typical loan(RANL &amp;amp; BUKRS combination) is around 200 records. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;some background info&lt;/U&gt;&lt;/P&gt;&lt;P&gt;I am currently testing this on our QA system, which is being run on virtual machine. The QA system has about 8 clients, 4 used for data migration. There is a database view called VDBEVI which is almost a combination of VDBEKI and VDBEVI. The project has not yet gone live, the current data in vdarl, vdbeki and vdbepi is just historical data.&lt;/P&gt;&lt;P&gt;VDARL (Loans Master)                                                                  17925 records&lt;/P&gt;&lt;P&gt;VDBEKI (Flow Data: Document Header for Actual Record)           1074417 records&lt;/P&gt;&lt;P&gt;VDBEPI (Posted line items for document header)                           1074417 records&lt;/P&gt;&lt;P&gt;there is a 1 to 1 relationship between VDBEKI and VDBEPI&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;I have attached a pic of the linkage between the 3 tables.&lt;/P&gt;&lt;P&gt;&lt;A href="http://farm5.static.flickr.com/4126/4998435206_49630dde67.jpg" target="test_blank"&gt;http://farm5.static.flickr.com/4126/4998435206_49630dde67.jpg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This a file containst the SQL trace for the report for a single loan&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.filedropper.com/summarytracefor1loan" target="test_blank"&gt;http://www.filedropper.com/summarytracefor1loan&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This file contrains the summary by SQL statement of the trace above&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.filedropper.com/tracelistfor1loan" target="test_blank"&gt;http://www.filedropper.com/tracelistfor1loan&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This a file containst the SQL trace for the report for 200 loans&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.filedropper.com/summarytracefor200loans" target="test_blank"&gt;http://www.filedropper.com/summarytracefor200loans&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a zip file with the 3 files above:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.filedropper.com/traces" target="test_blank"&gt;http://www.filedropper.com/traces&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for finding those notes. I read through the info for the notes you specified. I will need to sit with all the involved parties and discuss the implications and get the go-ahead before I can implement that. For the time being, I am waiting for a copy of the loans data to be made to one of the dev testing clients, then I can try the note in the dev environment. I will provide feeback once its implemented. For the second one, we are using SQL server DB as far as I'm aware, so I'm not sure whether the note is applicable??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Actions taken so far&lt;/U&gt;&lt;/P&gt;&lt;P&gt;-changing suitable internal tables to sorted tables&lt;/P&gt;&lt;P&gt;-removing additional layers\wrappers which incured unnecessary copy\time overheads&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;alternatives to consider&lt;/U&gt;&lt;/P&gt;&lt;P&gt;- adding indexes to both vdbeki and vdbepi to accomadate the join specified in my previous post. &lt;/P&gt;&lt;P&gt;- rewriting the standard LOAN_FLOWS_SUPPLY, using internal tables for vdarl and vdbepi&lt;/P&gt;&lt;P&gt;- applying notes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bijo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Bijo Samuel on Sep 20, 2010 4:37 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Sep 2010 14:37:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142122#M1513622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-20T14:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation question, internal table vs multiple DB calls</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142123#M1513623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry, those links aren't working&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can try this&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.filefactory.com/file/b38e2bh/n/traces.rar" target="test_blank"&gt;http://www.filefactory.com/file/b38e2bh/n/traces.rar&lt;/A&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.mediafire.com/?b346t8c5lz4p7vj" target="test_blank"&gt;http://www.mediafire.com/?b346t8c5lz4p7vj&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Sep 2010 17:30:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/optimisation-question-internal-table-vs-multiple-db-calls/m-p/7142123#M1513623</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-09-20T17:30:52Z</dc:date>
    </item>
  </channel>
</rss>

