<?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: Select performance issue in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260617#M1632091</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; As Yuri said, every thing is incorrect... let me take few cases:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;On OR Statement&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In some cases, it can be beneficial to simplify the WHERE conditions used on a LOOP iterator.  For example, if you have several conditions that check the same field against a set of values using OR operators, it can be beneficial to place the conditions in a RANGE or SELECT-OPTION object and change the WHERE clause to:  WHERE field IN [range] | [select-option].  The IN can be processed faster than several conditional statements joined by an OR (assuming you are using the same field as an operator).   Example:&lt;/P&gt;&lt;P&gt;GOOD:  u2026 WHERE field1 IN range1.&lt;/P&gt;&lt;P&gt;NOT AS GOOD: u2026 WHERE field1 = v1 OR field1 = v2 OR field1 = v3 OR field1 = v4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;On For All Entries&lt;/U&gt;&lt;/P&gt;&lt;P&gt;When using the FOR ALL ENTRIES clause, performance can be improved by increasing the blocking factor.  Since the FOR ALL ENTRIES clause essentially breaks down a table of records to be read into individual requests, the blocking factor controls how many of those records are grouped into a single request to the database.  The default blocking factor is 5.  For example, if the FOR ALL ENTRIES table contains 100 entries and the default blocking factor is used, then 20 separate requests for 5 records each will be sent to the database.  If the blocking factor is increased to 100, then only 1 request would be sent to the database to retrieve all 100 records.  This reduces the overhead needed to retrieve the data.  Be careful not to increase the blocking factor too high as it increases the length of the query and there are maximum limitations in the database that will generate a short-dump if exceeded.  The following Oracle u201Chintu201D can be added to queries to increase the blocking factor to 100 for that specific query only:  %_HINTS ORACLE '&amp;amp;min_in_blocking_factor 10&amp;amp;&amp;amp;max_in_blocking_factor 100&amp;amp;&amp;amp;min_blocking_factor 10&amp;amp;&amp;amp;max_blocking_factor 100&amp;amp;'.  Note that this hint will only optimize database queries when the FOR ALL ENTRIES clause is used and there are at least 100 entries expected in the result set&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;On Index&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Whenever possible, provide all fields in the primary key or index in the WHERE clause without gaps.  Itu2019s OK to leave a field off at the end of the primary key or index, but gaps within the primary key or index should be avoided.  For example, if an index is comprised of f1, f2, f3 and f4, then the following applies:&lt;/P&gt;&lt;P&gt;u2022	WHERE f1= v1 AND f2 = v2 AND f3 = v3 AND f4 = v4	OK&lt;/P&gt;&lt;P&gt;u2022	WHERE f1=v1 AND f2 = v2 AND f3 = v3			OK&lt;/P&gt;&lt;P&gt;u2022	WHERE f1 = v1 AND f3 = v3				Not recommended (gap)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Provide me URLs for thread where it has been proven that above is useless and incorrect!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen.I&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 31 Oct 2011 14:53:34 GMT</pubDate>
    <dc:creator>naveen_inuganti2</dc:creator>
    <dc:date>2011-10-31T14:53:34Z</dc:date>
    <item>
      <title>Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260606#M1632080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT vbap~matnr&lt;/P&gt;&lt;P&gt;       vbak~vbeln&lt;/P&gt;&lt;P&gt;       vbak~vdatu&lt;/P&gt;&lt;P&gt;       vbap~kwmeng&lt;/P&gt;&lt;P&gt;       vbap~pstyv&lt;/P&gt;&lt;P&gt;       INTO CORRESPONDING FIELDS OF TABLE lt_so_required&lt;/P&gt;&lt;P&gt;       FROM vbak JOIN vbap&lt;/P&gt;&lt;P&gt;         ON vbak&lt;SUB&gt;vbeln = vbap&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;       FOR ALL entries IN it_matnr&lt;/P&gt;&lt;P&gt;       WHERE vbap~matnr = it_matnr-matnr&lt;/P&gt;&lt;P&gt;         AND vbap~werks IN is_sel_scr-werks&lt;/P&gt;&lt;P&gt;         AND vbak~vdatu BETWEEN is_sel_scr-d_start&lt;/P&gt;&lt;P&gt;                           AND is_sel_scr-d_end&lt;/P&gt;&lt;P&gt;         AND vbak~auart IN is_sel_scr-auart&lt;/P&gt;&lt;P&gt;         AND vbak~vkorg = is_sel_scr-vkorg&lt;/P&gt;&lt;P&gt;         AND vbak~vtweg IN is_sel_scr-vtweg&lt;/P&gt;&lt;P&gt;         AND vbak~spart IN is_sel_scr-spart&lt;/P&gt;&lt;P&gt;         AND ( vbap~pstyv IN is_sel_scr-pstyvs OR&lt;/P&gt;&lt;P&gt;               vbap~pstyv IN is_sel_scr-pstyvo ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please point out the way of improving this select?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 08:53:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260606#M1632080</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-21T08:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260607#M1632081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbap~matnr&lt;/P&gt;&lt;P&gt;&amp;gt;        vbak~vbeln&lt;/P&gt;&lt;P&gt;&amp;gt;        vbak~vdatu&lt;/P&gt;&lt;P&gt;&amp;gt;        vbap~kwmeng&lt;/P&gt;&lt;P&gt;&amp;gt;        vbap~pstyv&lt;/P&gt;&lt;P&gt;&amp;gt;        INTO CORRESPONDING FIELDS OF TABLE lt_so_required&lt;/P&gt;&lt;P&gt;&amp;gt;        FROM vbak JOIN vbap&lt;/P&gt;&lt;P&gt;&amp;gt;          ON vbak&lt;SUB&gt;vbeln = vbap&lt;/SUB&gt;vbeln&lt;/P&gt;&lt;P&gt;&amp;gt;        FOR ALL entries IN it_matnr&lt;/P&gt;&lt;P&gt;&amp;gt;        WHERE vbap~matnr = it_matnr-matnr&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vbap~werks IN is_sel_scr-werks&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vbak~vdatu BETWEEN is_sel_scr-d_start&lt;/P&gt;&lt;P&gt;&amp;gt;                            AND is_sel_scr-d_end&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vbak~auart IN is_sel_scr-auart&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vbak~vkorg = is_sel_scr-vkorg&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vbak~vtweg IN is_sel_scr-vtweg&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vbak~spart IN is_sel_scr-spart&lt;/P&gt;&lt;P&gt;&amp;gt;          AND ( vbap~pstyv IN is_sel_scr-pstyvs OR&lt;/P&gt;&lt;P&gt;&amp;gt;                vbap~pstyv IN is_sel_scr-pstyvo ).&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Could you please point out the way of improving this select?&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello Wojciech,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please use the "index" table VAPMA for your selection and join it with VBAP.&lt;/P&gt;&lt;P&gt;The only field from VBAK I could not find in VAPMA is the VDATU. Please check if you can replace it with another field like AUDAT or some date field from VBAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then your select would look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;SELECT vapma~matnr&lt;/P&gt;&lt;P&gt;&amp;gt;        vapma~vbeln&lt;/P&gt;&lt;P&gt;&amp;gt;        vapma~audat &amp;lt;----  see my comment above about the date&lt;/P&gt;&lt;P&gt;&amp;gt;        vbap~kwmeng&lt;/P&gt;&lt;P&gt;&amp;gt;        vbap~pstyv&lt;/P&gt;&lt;P&gt;&amp;gt;        INTO CORRESPONDING FIELDS OF TABLE lt_so_required&lt;/P&gt;&lt;P&gt;&amp;gt;        FROM vapma INNER JOIN vbap&lt;/P&gt;&lt;P&gt;&amp;gt;          ON vapma&lt;SUB&gt;vbeln = vbap&lt;/SUB&gt;vbeln AND vapma&lt;SUB&gt;posnr = vbap&lt;/SUB&gt;posnr&lt;/P&gt;&lt;P&gt;&amp;gt;        FOR ALL entries IN it_matnr&lt;/P&gt;&lt;P&gt;&amp;gt;        WHERE vapma~matnr = it_matnr-matnr&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vapma~werks IN is_sel_scr-werks&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vapma~audat BETWEEN is_sel_scr-d_start  &amp;lt;---- see my comment about the date&lt;/P&gt;&lt;P&gt;&amp;gt;                            AND is_sel_scr-d_end&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vapma~auart IN is_sel_scr-auart&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vapma~vkorg = is_sel_scr-vkorg&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vapma~vtweg IN is_sel_scr-vtweg&lt;/P&gt;&lt;P&gt;&amp;gt;          AND vapma~spart IN is_sel_scr-spart&lt;/P&gt;&lt;P&gt;&amp;gt;          AND ( vbap~pstyv IN is_sel_scr-pstyvs OR&lt;/P&gt;&lt;P&gt;&amp;gt;                vbap~pstyv IN is_sel_scr-pstyvo ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Better results will be achieved if you also pass the value of VAPMA~TRVOG (Transaction Group) in the select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;  Yuri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 09:13:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260607#M1632081</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-10-21T09:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260608#M1632082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;unfortunately the date field is needed &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there any sense making the index on the tables?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 10:50:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260608#M1632082</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-21T10:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260609#M1632083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unfortunately the date field is needed :/&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; is there any sense making the index on the tables?&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hello Wojciech,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if this field is needed, then include VBAK as the third table in the join.&lt;/P&gt;&lt;P&gt;It might be beneficial to create a secondary index for VAPMA with the fields that are always specified in your selection. Due to the usage of select options I cannot see what else except material number is always (or very often) passed to the SELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;  Yuri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 12:34:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260609#M1632083</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-10-21T12:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260610#M1632084</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;Better use for all entries in select query instead of inner join..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2011 04:50:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260610#M1632084</guid>
      <dc:creator>mayankmrai</dc:creator>
      <dc:date>2011-10-28T04:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260611#M1632085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Better use for all entries in select query instead of inner join..&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Better read corresponding threads with the discussion FAE vs JOIN and do not give useless and wrong advices.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2011 09:14:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260611#M1632085</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-10-28T09:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260612#M1632086</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;Don't use 'Into Corresponding Fields Of' addition. Instead of that, you can declare structure(ref. internal table) with fields in same order they appear in SELECT query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't use BETWEEN statement, instead of that you might want to look at other options like ranges table etc.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Never go for OR statement because this causes double search on database. it's better to get all records instead and process what ever are required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Index Utility:&lt;/P&gt;&lt;P&gt;Ex: F1, F2, F3, F4 are fields and followed same order in index creation --&amp;gt;&lt;/P&gt;&lt;P&gt;F1, F2, F3 = using this in SELECT query triggers index&lt;/P&gt;&lt;P&gt;F2, F3, F4 = Using this in SELECT triggers index&lt;/P&gt;&lt;P&gt;F1, F2, F3, F4 = Also triggers Index&lt;/P&gt;&lt;P&gt;F1, F3, F4 = Never triggers index as was broken at F2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to add following oracle hint at the end of the SELECT query - This speeds up FOR ALL ENTRIES query as we are passing blocking factor as 10 and 100. NOTE: This does not apply if amount of data is less.&lt;/P&gt;&lt;P&gt;%_hints oracle '&amp;amp;min_in_blocking_factor 10&amp;amp;&amp;amp;max_in_blocking_factor 100&amp;amp;&amp;amp;min_blocking_factor 10&amp;amp;&amp;amp;max_blocking_factor 100&amp;amp;'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naveen Inuganti&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2011 09:19:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260612#M1632086</guid>
      <dc:creator>naveen_inuganti2</dc:creator>
      <dc:date>2011-10-28T09:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260613#M1632087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How much entries does your IT_MATNR host?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it´s around thousand or less you could make yourself a range table of MATNR for instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2011 09:23:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260613#M1632087</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-28T09:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260614#M1632088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Don't use 'Into Corresponding Fields Of' addition. Instead of that, you can declare structure(ref. internal table) with fields in same order they appear in SELECT query.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Don't use BETWEEN statement, instead of that you might want to look at other options like ranges table etc.,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Never go for OR statement because this causes double search on database. it's better to get all records instead and process what ever are required.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Index Utility:&lt;/P&gt;&lt;P&gt;&amp;gt; Ex: F1, F2, F3, F4 are fields and followed same order in index creation --&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;gt; F1, F2, F3 = using this in SELECT query triggers index&lt;/P&gt;&lt;P&gt;&amp;gt; F2, F3, F4 = Using this in SELECT triggers index&lt;/P&gt;&lt;P&gt;&amp;gt; F1, F2, F3, F4 = Also triggers Index&lt;/P&gt;&lt;P&gt;&amp;gt; F1, F3, F4 = Never triggers index as was broken at F2&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Try to add following oracle hint at the end of the SELECT query - This speeds up FOR ALL ENTRIES query as we are passing blocking factor as 10 and 100. NOTE: This does not apply if amount of data is less.&lt;/P&gt;&lt;P&gt;&amp;gt; %_hints oracle '&amp;amp;min_in_blocking_factor 10&amp;amp;&amp;amp;max_in_blocking_factor 100&amp;amp;&amp;amp;min_blocking_factor 10&amp;amp;&amp;amp;max_blocking_factor 100&amp;amp;'.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Thanks,&lt;/P&gt;&lt;P&gt;&amp;gt; Naveen Inuganti&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. "into corresponding fields" overhead is so little, that it should not be considered. So your advice number 1 is useless.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. What is a difference between "BETWEEN" statement and a range like "I BT XXX YYY"? Please support your statement with a link to an explanation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Second advice of not using OR statement is again wrong. It is not better to get all data from the DB and filter in ABAP. This has been discussed in many threads already.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. I have no idea what "index utility" is mentioned, but the text is simply wrong and confusing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Four useless/wrong advices in one post is too much for me...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 09:14:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260614#M1632088</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-10-31T09:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260615#M1632089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yuri,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thanks for going through all my options. Also please try it in editor once and come back here. &lt;/P&gt;&lt;P&gt;I have tried all of them, not my assumptions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Naveen Inuganti&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 11:27:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260615#M1632089</guid>
      <dc:creator>naveen_inuganti2</dc:creator>
      <dc:date>2011-10-31T11:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260616#M1632090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Naveen - if you go through old forum posts, you'll find that Yuri is correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I &lt;EM&gt;have&lt;/EM&gt; tried all of your options &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&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, 31 Oct 2011 13:23:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260616#M1632090</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-31T13:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260617#M1632091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; As Yuri said, every thing is incorrect... let me take few cases:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;On OR Statement&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In some cases, it can be beneficial to simplify the WHERE conditions used on a LOOP iterator.  For example, if you have several conditions that check the same field against a set of values using OR operators, it can be beneficial to place the conditions in a RANGE or SELECT-OPTION object and change the WHERE clause to:  WHERE field IN [range] | [select-option].  The IN can be processed faster than several conditional statements joined by an OR (assuming you are using the same field as an operator).   Example:&lt;/P&gt;&lt;P&gt;GOOD:  u2026 WHERE field1 IN range1.&lt;/P&gt;&lt;P&gt;NOT AS GOOD: u2026 WHERE field1 = v1 OR field1 = v2 OR field1 = v3 OR field1 = v4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;On For All Entries&lt;/U&gt;&lt;/P&gt;&lt;P&gt;When using the FOR ALL ENTRIES clause, performance can be improved by increasing the blocking factor.  Since the FOR ALL ENTRIES clause essentially breaks down a table of records to be read into individual requests, the blocking factor controls how many of those records are grouped into a single request to the database.  The default blocking factor is 5.  For example, if the FOR ALL ENTRIES table contains 100 entries and the default blocking factor is used, then 20 separate requests for 5 records each will be sent to the database.  If the blocking factor is increased to 100, then only 1 request would be sent to the database to retrieve all 100 records.  This reduces the overhead needed to retrieve the data.  Be careful not to increase the blocking factor too high as it increases the length of the query and there are maximum limitations in the database that will generate a short-dump if exceeded.  The following Oracle u201Chintu201D can be added to queries to increase the blocking factor to 100 for that specific query only:  %_HINTS ORACLE '&amp;amp;min_in_blocking_factor 10&amp;amp;&amp;amp;max_in_blocking_factor 100&amp;amp;&amp;amp;min_blocking_factor 10&amp;amp;&amp;amp;max_blocking_factor 100&amp;amp;'.  Note that this hint will only optimize database queries when the FOR ALL ENTRIES clause is used and there are at least 100 entries expected in the result set&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;On Index&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Whenever possible, provide all fields in the primary key or index in the WHERE clause without gaps.  Itu2019s OK to leave a field off at the end of the primary key or index, but gaps within the primary key or index should be avoided.  For example, if an index is comprised of f1, f2, f3 and f4, then the following applies:&lt;/P&gt;&lt;P&gt;u2022	WHERE f1= v1 AND f2 = v2 AND f3 = v3 AND f4 = v4	OK&lt;/P&gt;&lt;P&gt;u2022	WHERE f1=v1 AND f2 = v2 AND f3 = v3			OK&lt;/P&gt;&lt;P&gt;u2022	WHERE f1 = v1 AND f3 = v3				Not recommended (gap)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Provide me URLs for thread where it has been proven that above is useless and incorrect!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen.I&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 14:53:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260617#M1632091</guid>
      <dc:creator>naveen_inuganti2</dc:creator>
      <dc:date>2011-10-31T14:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260618#M1632092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please provide SAP documentation that shows this is correct.&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, 31 Oct 2011 15:23:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260618#M1632092</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-31T15:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260619#M1632093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, Naveen, let's go...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;U&gt;On OR Statement&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; In some cases, it can be beneficial to simplify the WHERE conditions used on a LOOP iterator.  For example, if you have several conditions that check the same field against a set of values using OR operators, it can be beneficial to place the conditions in a RANGE or SELECT-OPTION object and change the WHERE clause to:  WHERE field IN [range] | [select-option].  The IN can be processed faster than several conditional statements joined by an OR (assuming you are using the same field as an operator).   Example:&lt;/P&gt;&lt;P&gt;&amp;gt; GOOD:  u2026 WHERE field1 IN range1.&lt;/P&gt;&lt;P&gt;&amp;gt; NOT AS GOOD: u2026 WHERE field1 = v1 OR field1 = v2 OR field1 = v3 OR field1 = v4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is absolutely the same. There is no single reason why IN list should be faster than OR. Wasted time for changing the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;U&gt;On For All Entries&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; When using the FOR ALL ENTRIES clause, performance can be improved by increasing the blocking factor.  Since the FOR ALL ENTRIES clause essentially breaks down a table of records to be read into individual requests, the blocking factor controls how many of those records are grouped into a single request to the database.  The default blocking factor is 5.  For example, if the FOR ALL ENTRIES table contains 100 entries and the default blocking factor is used, then 20 separate requests for 5 records each will be sent to the database.  If the blocking factor is increased to 100, then only 1 request would be sent to the database to retrieve all 100 records.  This reduces the overhead needed to retrieve the data.  Be careful not to increase the blocking factor too high as it increases the length of the query and there are maximum limitations in the database that will generate a short-dump if exceeded.  The following Oracle u201Chintu201D can be added to queries to increase the blocking factor to 100 for that specific query only:  %_HINTS ORACLE '&amp;amp;min_in_blocking_factor 10&amp;amp;&amp;amp;max_in_blocking_factor 100&amp;amp;&amp;amp;min_blocking_factor 10&amp;amp;&amp;amp;max_blocking_factor 100&amp;amp;'.  Note that this hint will only optimize database queries when the FOR ALL ENTRIES clause is used and there are at least 100 entries expected in the result set&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you carefully read my reply, I &lt;STRONG&gt;did not&lt;/STRONG&gt; comment your statement regarding max_blocking_factor. Indeed it can help in many cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;U&gt;On Index&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Whenever possible, provide all fields in the primary key or index in the WHERE clause without gaps.  Itu2019s OK to leave a field off at the end of the primary key or index, but gaps within the primary key or index should be avoided.  For example, if an index is comprised of f1, f2, f3 and f4, then the following applies:&lt;/P&gt;&lt;P&gt;&amp;gt; u2022	WHERE f1= v1 AND f2 = v2 AND f3 = v3 AND f4 = v4	OK&lt;/P&gt;&lt;P&gt;&amp;gt; u2022	WHERE f1=v1 AND f2 = v2 AND f3 = v3			OK&lt;/P&gt;&lt;P&gt;&amp;gt; u2022	WHERE f1 = v1 AND f3 = v3				Not recommended (gap)&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sure this is correct, but it's so obvious that almost nobody is mentioning this stuff in this forum anymore. It can be found in thousands of places in Internet. It's like common sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And well, there is a little difference to what you have said before. Let me remind you...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; F2, F3, F4 = Using this in SELECT triggers index&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Don't you see the "gap" at field1? So your original "advice" was incorrect as I already mentioned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And believe me, I am doing performance optimizations for many SAP customers for the last 7 years. If somebody tells me something new, I always ask for the technical explanation (because as the end of the day the customer will ask me why did I advise something like this?). Without the technical explanation why certain thing is faster than another one, I don't trust anyone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;  Yuri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 08:35:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260619#M1632093</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-11-02T08:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260620#M1632094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;there was an old recommendation to change ORs into IN-list (no ranges but IN (a, b, ...) programmed. I do not know whether this is still valid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;F1, F2, F3 = using this in SELECT query triggers index&lt;/P&gt;&lt;P&gt;&amp;gt;F2, F3, F4 = Using this in SELECT triggers index&lt;/P&gt;&lt;P&gt;&amp;gt;F1, F2, F3, F4 = Also triggers Index&lt;/P&gt;&lt;P&gt;&amp;gt;F1, F3, F4 = Never triggers index as was broken at F2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only option 3 is correct, if the key is the primary key, because this is unique&lt;/P&gt;&lt;P&gt;All others depend on costs and available other indexes.&lt;/P&gt;&lt;P&gt;Option 2 is a misinterpretation of the Oracle skip scan: Works only if different values for f1 are small and only for Oracle.&lt;/P&gt;&lt;P&gt;Option 4 again assums low selectivity for F1, because it would work fine, if the selectivity of f1 is high.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replacing joins by FAE was discussed often ... the solution is 'it depends'.&lt;/P&gt;&lt;P&gt;Changing blocking factor - either generally or with a hint - is not recommended. This should only be done, if it is absolutely clear, how the statement is used (size of table, size of driver can normally vary a lot)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 12:57:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260620#M1632094</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-02T12:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260621#M1632095</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;this is the real fun with modern databases. They are so clever...&lt;/P&gt;&lt;P&gt;This is an example from my toy-around 11g babe:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SQL&amp;gt; select * from emp where empno=7369 or empno=7900;

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30

---------------------------------------------------------------------------------------
| Id  | Operation                    | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |        |     2 |    64 |     2   (0)| 00:00:01 |
|   1 |  INLIST ITERATOR             |        |       |       |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID| EMP    |     2 |    64 |     2   (0)| 00:00:01 |
|*  3 |    INDEX UNIQUE SCAN         | PK_EMP |     2 |       |     1   (0)| 00:00:01 |
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   3 - access("EMPNO"=7369 OR "EMPNO"=7900)

Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
          4  consistent gets
          1  physical reads
          0  redo size
        939  bytes sent via SQL*Net to client
        420  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          2  rows processed

SQL&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I feel the need to pad on it's back mumbeling "good boy".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the DB decides for an inlist iteration if you provide OR clauses on the same column.&lt;/P&gt;&lt;P&gt;Since some time you can not even override this with a use_concat hint any more.&lt;/P&gt;&lt;P&gt;The hint is still there, but does not seem to work when the same column is "OR"ed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the statement is in fact not transformed to a different plan any more,&lt;/P&gt;&lt;P&gt;unless you are still using a very old version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Volker&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 22:07:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260621#M1632095</guid>
      <dc:creator>volker_borowski2</dc:creator>
      <dc:date>2011-11-02T22:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260622#M1632096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excellent, thanks for the confirmation, Volker.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2011 08:03:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance-issue/m-p/8260622#M1632096</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-11-03T08:03:54Z</dc:date>
    </item>
  </channel>
</rss>

