<?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: Strange performance problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086099#M1506655</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Table RESB has index M that would work very well with this query. I do not think the select statement is a problem. It could have something to do with the following macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resb_check atp_resb
                       p_atpmex.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Double click 'resb_check' and it will show you the following code in include LATP2TMR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DEFINE resb_check.
  case &amp;amp;1-bdart.
    when skbed or brbed.
      perform resb_skbed_brbed_check
              tables &amp;amp;2
              using  &amp;amp;1.
    when arbed or mrbed.
      perform resb_arbed_mrbed_check
              tables &amp;amp;2
              using  &amp;amp;1.
  endcase.
END-OF-DEFINITION.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look at subroutines 'resb_skbed_brbed_check' and 'resb_arbed_mrbed_check'. Your problem might lie there rather than in the select statement you are looking at.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Jul 2010 14:57:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-07-08T14:57:02Z</dc:date>
    <item>
      <title>Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086094#M1506650</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;We have huge performance problems with ATP check when creating production order - but only in development system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have debugged and isolated the problem to one select statement that is performed for every component in BOM. The select is found in  SAPLATP2 FORM RESB_DB_READ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This select uses about 300 seconds, but I have tried to copy the select statement to a test program, and tested with same matnr and werks. Then the select statement uses less than 1 second.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This I find very strange - any explanation will be appreciated. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;        
...
IF  s_sbed &amp;gt; 0.
ENHANCEMENT-SECTION     RESB_DB_READ_05 SPOTS ES_SAPLATP2.
          SELECT *
          FROM   atp_resb
          INTO   atp_resb
          WHERE  matnr = atpmat-matnr
          AND    werks = atpmat-werks
          AND    xloek = space
          AND    kzear = space
          AND    sobkz IN (space, sobkzk)
          AND    bdmng &amp;gt; atp_resb~enmng
          AND    txtps = space
          AND    schgt = space
          AND    dbskz = space
          AND  ( vorab IS NULL
              OR vorab = space ).
            CLEAR atp_resb-sobkz.
*         checks
            resb_check atp_resb
                       p_atpmex.
          ENDSELECT.
END-ENHANCEMENT-SECTION.
...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jul 2010 14:05:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086094#M1506650</guid>
      <dc:creator>TMNielsen</dc:creator>
      <dc:date>2010-07-08T14:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086095#M1506651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you compare the ST05 execution plans for both the actual case and your test case? Please paste them here to allow a remote analysis. Plus whatever the actual experts here might want to know from you.&lt;/P&gt;&lt;P&gt;I assume your test case was performed in the same box where the problem occurs.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jul 2010 14:37:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086095#M1506651</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2010-07-08T14:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086096#M1506652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming all of the parameters are the same for both executions, make sure your SQL statement cache is cleared before each execution (DB02 or ask your Basis counterpart for assistance).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jul 2010 14:48:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086096#M1506652</guid>
      <dc:creator>brad_bohn</dc:creator>
      <dc:date>2010-07-08T14:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086097#M1506653</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;I'm not sure what you mean by "ST05 execution plans"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jul 2010 14:48:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086097#M1506653</guid>
      <dc:creator>TMNielsen</dc:creator>
      <dc:date>2010-07-08T14:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086098#M1506654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; I'm not sure what you mean by "ST05 execution plans"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;have a look here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/hermann.gahm/blog/2010/03/04/explaining-the-explain-plan&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>Thu, 08 Jul 2010 14:51:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086098#M1506654</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-07-08T14:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086099#M1506655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Table RESB has index M that would work very well with this query. I do not think the select statement is a problem. It could have something to do with the following macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resb_check atp_resb
                       p_atpmex.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Double click 'resb_check' and it will show you the following code in include LATP2TMR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DEFINE resb_check.
  case &amp;amp;1-bdart.
    when skbed or brbed.
      perform resb_skbed_brbed_check
              tables &amp;amp;2
              using  &amp;amp;1.
    when arbed or mrbed.
      perform resb_arbed_mrbed_check
              tables &amp;amp;2
              using  &amp;amp;1.
  endcase.
END-OF-DEFINITION.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look at subroutines 'resb_skbed_brbed_check' and 'resb_arbed_mrbed_check'. Your problem might lie there rather than in the select statement you are looking at.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jul 2010 14:57:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086099#M1506655</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-08T14:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086100#M1506656</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;Brad Bohns suggestion actually was the solution. I did clear the SQL statement cache in ST04 and the problem was gone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SQL explain of the statement in ST05 showed that the statement would use index M and O on table RESB, but the actual execution explain in ST04 showed a full table scan. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some unknown reason the program would find a wrong cached SQL statement, so when the cache was cleared, the problem was gone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have heard of this possibility before - in 2004 when I took the BC490 SAP course - ABAP Performance Tuning, but I have never actually seen the problem before.  I don't think this info was a part of the official SAP course, but I remember that the instructor mentioned this possible problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lesson learned and problem solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Thomas Madsen Nielsen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 05:37:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086100#M1506656</guid>
      <dc:creator>TMNielsen</dc:creator>
      <dc:date>2010-07-09T05:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086101#M1506657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, the recommendations to check the execution plan/explain is the common approach. There you would figure out, that they are different. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you know that, it is not so difficult to come to the conclusion, that a refresh of the cache can help. The cache can be outdated, if a new index was created or if the data distribution has changed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not like the random guessing approach too much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 06:52:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086101#M1506657</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-09T06:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086102#M1506658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also don't like the random guessing approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However in this case I don't understand what was the cause of the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know for sure that it was not a new index created and that it was not because the data distribution has changed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I guess that the first attempt to execute this SQL statment after the last time the cache was cleared, was in some way with an atypical parameter list, that resulted in a full table scan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- and yes - I know it - I used the "guess" word again  ;o)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards &lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 07:18:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086102#M1506658</guid>
      <dc:creator>TMNielsen</dc:creator>
      <dc:date>2010-07-09T07:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086103#M1506659</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;just for clarifcation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;are you running on MSSQL? or another database?&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>Fri, 09 Jul 2010 07:53:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086103#M1506659</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-07-09T07:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086104#M1506660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We use MSSQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 07:58:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086104#M1506660</guid>
      <dc:creator>TMNielsen</dc:creator>
      <dc:date>2010-07-09T07:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086105#M1506661</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;&lt;/P&gt;&lt;P&gt;the creation of the index will invalidate the statement of the cache. Therefore for any statement executed after&lt;/P&gt;&lt;P&gt;the new index was created the optimizer will see it and take it into account and will not use an old cached plan.&lt;/P&gt;&lt;P&gt;As far as i know this is true on all databases that are supported by SAP. (i never came across problems here).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data distribution changes... now we talk about statistics. Same databases do not have a problem with this.&lt;/P&gt;&lt;P&gt;E.g. MaxDB since they do a so called evaluation all the time. The new version of DB6 (9.5 or 9.7) uses so &lt;/P&gt;&lt;P&gt;called real time statistics and at least theoretically should see the new data distribution as well (of course&lt;/P&gt;&lt;P&gt;there is some threshold where this feature kicks in, below the threshold the old behaviour is valid. The old&lt;/P&gt;&lt;P&gt;behaviour is what we have on all other databases as far as i know. The old cached plan is used the new&lt;/P&gt;&lt;P&gt;data distribution is only taken into account when new statistics are created. The creation of new statistics&lt;/P&gt;&lt;P&gt;leads to invalidation of the old plans.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your problem it is most likely (this is an educated guess), as you said, the parameter issue. MSSQL &lt;/P&gt;&lt;P&gt;evaluates the parameters for the FIRST execution of a statement. These parameters led to a full table&lt;/P&gt;&lt;P&gt;scan in your case. All other statements with different parameters will use that plan until the sql statement&lt;/P&gt;&lt;P&gt;is invalidated in the cache. On MSSQL this happens if:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- a new index is created&lt;/P&gt;&lt;P&gt;- new statistics are created&lt;/P&gt;&lt;P&gt;- the statement is recompiled / reparsed  (then the parameters for the execution with the recompile / reparse hint are used).&lt;/P&gt;&lt;P&gt;- the statement cache is cleared / invalidated &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A new plan will be build as well if the statement is displaced from the statement cache.&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>Fri, 09 Jul 2010 08:08:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086105#M1506661</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-07-09T08:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086106#M1506662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Herman&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was a very usefull overview. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both the info about how different databases use statistics and the info about cache invalidation is very interesting. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering when the cache was cleared, and you answered that question before I even asked it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Amazing!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 08:16:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086106#M1506662</guid>
      <dc:creator>TMNielsen</dc:creator>
      <dc:date>2010-07-09T08:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Strange performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086107#M1506663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; I'm not sure what you mean by "ST05 execution plans"?&lt;/P&gt;&lt;P&gt;My comment referred to this, because I think it is more important to know how to analyse than to know the internal of the databases. It depends of course whether you use exactly one db or several even in different releases.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 14:56:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/strange-performance-problem/m-p/7086107#M1506663</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-09T14:56:00Z</dc:date>
    </item>
  </channel>
</rss>

