<?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 Range: Initial is better? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484735#M1061713</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello guys!!&lt;/P&gt;&lt;P&gt;Please, look this two examples about performance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;SELECT  bukrs belnr gjahr blart budat&lt;/P&gt;&lt;P&gt;    FROM  bkpf&lt;/P&gt;&lt;P&gt;    INTO  TABLE bkpf_int&lt;/P&gt;&lt;P&gt;    WHERE bukrs EQ p_bukrs&lt;/P&gt;&lt;P&gt;    AND   bstat IN (' ', 'A', 'B', 'D', 'M', 'S', 'V', 'W', 'Z')&lt;/P&gt;&lt;P&gt;    AND   budat = bkpf_wa-budat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example 2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;RANGES: r_bstat FOR bkpf-bstat.&lt;/P&gt;&lt;P&gt;SELECT  bukrs belnr gjahr blart budat&lt;/P&gt;&lt;P&gt;    FROM  bkpf&lt;/P&gt;&lt;P&gt;    INTO  TABLE bkpf_int&lt;/P&gt;&lt;P&gt;    WHERE bukrs EQ p_bukrs&lt;/P&gt;&lt;P&gt;    AND   bstat IN r_bstat       "Range initial, without values.&lt;/P&gt;&lt;P&gt;    AND   budat = bkpf_wa-budat. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question:&lt;/P&gt;&lt;P&gt;What is better?? What is faster?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Sep 2008 13:26:42 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-15T13:26:42Z</dc:date>
    <item>
      <title>Range: Initial is better?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484735#M1061713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello guys!!&lt;/P&gt;&lt;P&gt;Please, look this two examples about performance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;SELECT  bukrs belnr gjahr blart budat&lt;/P&gt;&lt;P&gt;    FROM  bkpf&lt;/P&gt;&lt;P&gt;    INTO  TABLE bkpf_int&lt;/P&gt;&lt;P&gt;    WHERE bukrs EQ p_bukrs&lt;/P&gt;&lt;P&gt;    AND   bstat IN (' ', 'A', 'B', 'D', 'M', 'S', 'V', 'W', 'Z')&lt;/P&gt;&lt;P&gt;    AND   budat = bkpf_wa-budat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example 2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;RANGES: r_bstat FOR bkpf-bstat.&lt;/P&gt;&lt;P&gt;SELECT  bukrs belnr gjahr blart budat&lt;/P&gt;&lt;P&gt;    FROM  bkpf&lt;/P&gt;&lt;P&gt;    INTO  TABLE bkpf_int&lt;/P&gt;&lt;P&gt;    WHERE bukrs EQ p_bukrs&lt;/P&gt;&lt;P&gt;    AND   bstat IN r_bstat       "Range initial, without values.&lt;/P&gt;&lt;P&gt;    AND   budat = bkpf_wa-budat. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question:&lt;/P&gt;&lt;P&gt;What is better?? What is faster?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2008 13:26:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484735#M1061713</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-15T13:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Range: Initial is better?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484736#M1061714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ranges are obselete in ECC 6.0 , so use IN ( like the 1st ). You can check the performance in se30 .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2008 13:29:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484736#M1061714</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-15T13:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Range: Initial is better?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484737#M1061715</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;Ranges are obselete in ECC 6.0 ...&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you mean the statement RANGES is obsolate, but we can still freely define ranges with ... TYPE RANGE OF ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;back to the original question: the 2nd example proved to be faster in my test.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2008 13:36:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484737#M1061715</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2008-09-15T13:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Range: Initial is better?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484738#M1061716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There should be no difference. You can check this by running both multiple times or by looking at the EXPLAIN in ST05.&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, 15 Sep 2008 13:43:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484738#M1061716</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-15T13:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Range: Initial is better?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484739#M1061717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your question &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;What is better?? What is faster?&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;has very little meaning when talking about performance tuning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Performance will vary depending on a number of factors - for example what database?, what version?, what optimisation method?, how many records in the table?, is the database on the same machine as the application server? or are they on different architectures even?, what cacheing / buffering is there?, are the statistics up to date?, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tools such as ST05 and SE30 will allow you to look at how each is performing in your environment.  Look at the execution plan the optimiser picks for the SQL in each case - is it using indexes?  is it the same one in each case?  is it just doing a table scan because there are not many records?  Also look at things like how many fetches there are from the database server to the application server, and are these efficient with each returning a number of records appropriate to your architecture?.  Check articles in the WIKI or in Blogs for lots of detailed hints on what to look for - but dont expect that everything that helps someone else will work in your environment in the same way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While it often possible to say that a particular SQL statement will perform badly - eg not using any indexed fields in the where block, to find what is optimum for a particular program on a particular system it is normally necessary to do the detailed analysis work - first in the development system to get the basics correct, but then often in the QA or Production (copy) system when it turns out that it performs differently with a different data volume or for some other reason.   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest that in your examples, in the second case with the empty ranges table, it is possible that SAP will not even mention the BSTAT field in the SQL it generates and passes to the database - which will possibly result in a different index being used giving a faster or slower read.  Dont know for sure - have never looked at how SAP handles empty ranges.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2008 14:41:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484739#M1061717</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-15T14:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Range: Initial is better?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484740#M1061718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The second selection is equivalent to :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT bukrs belnr gjahr blart budat&lt;/P&gt;&lt;P&gt;  FROM bkpf&lt;/P&gt;&lt;P&gt;  INTO TABLE bkpf_int&lt;/P&gt;&lt;P&gt;  WHERE bukrs EQ p_bukrs&lt;/P&gt;&lt;P&gt;  AND budat = wa_bkpf-budat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As in the 2 cases, the database will use index BKPF~2 (on fields BUKRS / BSTAT / BUDAT), we can think that the first solution (with BSTAT in (' ', 'A', ...)) will be better than the second one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in fact, specifying a lot of different BSTAT forces the database to read more data from the index (it has to read the field BSTAT). Furthermore when the table is not very large, specifying more conditions can force the database to read a lot of times the same block of memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's why specifying this field is useful mainly when it is on rarely used values but not when specifying all existing values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Sep 2008 10:08:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484740#M1061718</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-16T10:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Range: Initial is better?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484741#M1061719</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;Always better to &lt;STRONG&gt;restrict&lt;/STRONG&gt; the result set as much as possible. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;You don't restrict if you give all possible values to the IN LIST (1st select)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;i.e. The IN LIST will be transformed to OR statements by the database (makes the 1st a more complex query and possibly makes it more difficult to get a good execution plan) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;You don't restrict if you give no IN LIST at all (2nd select)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;it omits the IN LIST and leaves only a limited choice of execution plans for the optimizer &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then it's up to the database optimizer what execution path he's choosing (cost based otpimization: depends on data volume , your table and index statistics) or rule optimization.&lt;/P&gt;&lt;P&gt;In this case it possibly would come out with the same execution plan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is NEVER a general rule if you do this or avoid that it will be better for performance. &lt;/P&gt;&lt;P&gt;Sometimes IN is the key to survive , sometimes it will kill your application response time,&lt;/P&gt;&lt;P&gt;sometimes it makes no difference at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sure there are common pitfalls to be avoided or positively speaking:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;know your database you are running on&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Benchmark your different statements.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;use ST05 and look HOW the SQL is processed by the database&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;take the needed actions to improve (SELECT or the data model i.e. meaningful indexing scheme)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bye &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Sep 2008 06:22:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/range-initial-is-better/m-p/4484741#M1061719</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-23T06:22:57Z</dc:date>
    </item>
  </channel>
</rss>

