<?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. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888760#M1595590</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;Please make sure control goes to 3rd select statement only when it_vbrk is not empty. If its empty, select query will select all the data (which can be huge) and hence performance problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;KS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;removed by moderator&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Thomas Zloch on May 2, 2011 12:35 PM - please do not ask for ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 May 2011 05:46:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-05-02T05:46:44Z</dc:date>
    <item>
      <title>Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888757#M1595587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, i ahve a problem with "select", when i pass my report to 'production' . Please  can i add performance this select :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 :&lt;/P&gt;&lt;P&gt;     SELECT zznumfisc belnr cpudt waers blart xblnr                "CARGANDO NOTAS DE CREDITO EMITIDAS&lt;/P&gt;&lt;P&gt;        INTO  TABLE it_aux_bkpf&lt;/P&gt;&lt;P&gt;        FROM bkpf&lt;/P&gt;&lt;P&gt;        WHERE bukrs = p_bukrs           AND&lt;/P&gt;&lt;P&gt;           belnr in r_belnr                    and&lt;/P&gt;&lt;P&gt;           gjahr in r_gjahr                    and&lt;/P&gt;&lt;P&gt;           cpudt IN so_cpudt              AND&lt;/P&gt;&lt;P&gt;           waers = p_waers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 :    SELECT bukrs kunnr belnr budat waers xblnr&lt;/P&gt;&lt;P&gt;         blart wrbtr hkont zfbdt zterm vbeln&lt;/P&gt;&lt;P&gt;         shkzg augbl&lt;/P&gt;&lt;P&gt;         INTO  TABLE it_tbsad&lt;/P&gt;&lt;P&gt;        FROM bsad&lt;/P&gt;&lt;P&gt;        WHERE bukrs = p_bukrs&lt;/P&gt;&lt;P&gt;             AND kunnr IN so_kunnr&lt;/P&gt;&lt;P&gt;             AND umsks IN r_umsks&lt;/P&gt;&lt;P&gt;             AND umskz IN r_umskz&lt;/P&gt;&lt;P&gt;             AND augdt IN r_augdt&lt;/P&gt;&lt;P&gt;             AND augbl IN r_augbl&lt;/P&gt;&lt;P&gt;             AND zuonr IN r_zuonr&lt;/P&gt;&lt;P&gt;             AND gjahr IN r_gjahr&lt;/P&gt;&lt;P&gt;             AND belnr IN r_belnr&lt;/P&gt;&lt;P&gt;             AND buzei IN r_buzei&lt;/P&gt;&lt;P&gt;             AND budat IN so_datum&lt;/P&gt;&lt;P&gt;             AND zterm IN so_zterm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 :  SELECT vbeln matkl matnr arktx fkimg erdat vrkme vkorg_auft vtweg_auft netwr    FROM vbrp INTO TABLE it_vbrp&lt;/P&gt;&lt;P&gt;      FOR ALL ENTRIES IN it_vbrk&lt;/P&gt;&lt;P&gt;      WHERE vbeln = it_vbrk-vbeln and"AND  matkl      = 'ZPTER0032'.&lt;/P&gt;&lt;P&gt;            posnr in r_posnr      and&lt;/P&gt;&lt;P&gt;            matkl in ('zpter0032','zpter0017','zpter0035','zpter0023','zpter0026','zpter0037') and&lt;/P&gt;&lt;P&gt;            erdat in so_erdat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2011 18:41:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888757#M1595587</guid>
      <dc:creator>rtupino</dc:creator>
      <dc:date>2011-04-29T18:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888758#M1595588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;- Make sure that your ranges are as specific as possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Make sure that at least one parameter/select option/range for an indexed field is populated in each select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Check that it_vbrk is not initilal before select #3.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Apr 2011 19:06:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888758#M1595588</guid>
      <dc:creator>alex_campbell</dc:creator>
      <dc:date>2011-04-29T19:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888759#M1595589</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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where is your it_vbrk table   ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note :Before passing data to 3# query &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if it_vbrk[] is not initial  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 : SELECT vbeln matkl matnr arktx fkimg erdat vrkme vkorg_auft vtweg_auft netwr FROM vbrp INTO TABLE it_vbrp&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN it_vbrk&lt;/P&gt;&lt;P&gt;WHERE vbeln = it_vbrk-vbeln&lt;/P&gt;&lt;P&gt; and posnr in r_posnr &lt;/P&gt;&lt;P&gt;and matkl in ('zpter0032','zpter0017','zpter0035','zpter0023','zpter0026','zpter0037') and&lt;/P&gt;&lt;P&gt;erdat in so_erdat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note:  table it_vbrk is blank before passing to query 3# then  it iwll go in infitnite loop  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it will hamper  performance of query   and also check whether  you are selecting all primary fields in select query  for respective table  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 Apr 2011 09:01:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888759#M1595589</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2011-04-30T09:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888760#M1595590</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;Please make sure control goes to 3rd select statement only when it_vbrk is not empty. If its empty, select query will select all the data (which can be huge) and hence performance problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;KS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;removed by moderator&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Thomas Zloch on May 2, 2011 12:35 PM - please do not ask for ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2011 05:46:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888760#M1595590</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-02T05:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888761#M1595591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please understand what the RANGES mean, it is dynamic coding!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would expect that there are no problems if all ranges are filled, and there are lots if no range is filled.&lt;/P&gt;&lt;P&gt;So you can have any problem with these SELECTs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which range do you want to support?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2011 08:36:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888761#M1595591</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-02T08:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888762#M1595592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. When you query from tables like BSAD (Which are always huge) try to reduce restricting the number of entries within the query like putting more conditions in the where clause (there are chance you might go into a timeout). Instead try with few conditions in where clause(according to the secondary index created for the table BSAD).&lt;/P&gt;&lt;P&gt;2. No query is perfect at start try to run a SQL trace and make sure your query is using the Index you wanted to&lt;/P&gt;&lt;P&gt;3. When you use For all entries make sure that table has entries&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2011 17:58:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888762#M1595592</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-02T17:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888763#M1595593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all comments, i appreciate your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2011 14:11:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888763#M1595593</guid>
      <dc:creator>rtupino</dc:creator>
      <dc:date>2011-05-03T14:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888764#M1595594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With large tables it is best to avoid WHERE statements for non-indexed fields. Consider dropping any non-indexed fields from the select query and instead loop through the returned results to filter out unwanted records in a separate step. The benefit of this all depends on the number of records retrieved with the non-indexed fields in the query and the number of records without those fields. The only way to be certain of the result is to test it with realistic data volumes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 14:48:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888764#M1595594</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-05T14:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888765#M1595595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how did you come to the idea to drop the where clause for the select statement and filter in ABAP?&lt;/P&gt;&lt;P&gt;This is absolutely incorrect advice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yuri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 15:00:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888765#M1595595</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-05-05T15:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888766#M1595596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yuri,&lt;/P&gt;&lt;P&gt;John is correct on this. Test this out for yourself. The first Select above is a perfect example. Perform select bkpf without currency and cpudt run it. And then run with the two non-key fields as above. &lt;/P&gt;&lt;P&gt;You have to do some analysis on the table and queries in question. It is not always cut and dried. And when it's feasible and beneficial, a secondary index including all fields would be the correct way to code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 May 2011 19:49:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888766#M1595596</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-11T19:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888767#M1595597</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;&amp;gt; John is correct on this. Test this out for yourself. The first Select above is a perfect example. Perform select bkpf without currency and cpudt run it. And then run with the two non-key fields as above. &lt;/P&gt;&lt;P&gt;&amp;gt; You have to do some analysis on the table and queries in question. It is not always cut and dried. And when it's feasible and beneficial, a secondary index including all fields would be the correct way to code. &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Buffering is the issue here. If instead of running the SELECTs one after another, you run them after an interval, I think you'll see that eliminating the WHERE does not help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And adding indexes should be avoided.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And CPUDT &lt;U&gt;is&lt;/U&gt; an index field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on May 11, 2011 4:55 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 May 2011 20:03:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888767#M1595597</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-11T20:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888768#M1595598</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;Yuri,&lt;/P&gt;&lt;P&gt;&amp;gt; John is correct on this. Test this out for yourself. The first Select above is a perfect example. Perform select bkpf without currency and cpudt run it. And then run with the two non-key fields as above. &lt;/P&gt;&lt;P&gt;&amp;gt; You have to do some analysis on the table and queries in question. It is not always cut and dried. And when it's feasible and beneficial, a secondary index including all fields would be the correct way to code. &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Filler&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filler, please read the answer of Rob above. &lt;/P&gt;&lt;P&gt;again, eliminating WHERE clause does not help. Moreover, it makes things slower.&lt;/P&gt;&lt;P&gt;If you understand, how ABAP, SAP DB interface and the Database itself work and communicate with each other the answer becomes obvious.&lt;/P&gt;&lt;P&gt;The only case when it can help is when DB is selecting the wrong access path due to the existence of similar indexes or outdated statistics or a bug in DB.&lt;/P&gt;&lt;P&gt;But I would never base my recommendations on that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 07:33:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888768#M1595598</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-05-12T07:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888769#M1595599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;Consider dropping any non-indexed fields from the select query and instead&lt;/P&gt;&lt;P&gt;&amp;gt;loop through the returned results to filter out unwanted records in a separate step. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;incorrect and not recommended. The correct usage of indexes is a never ending story, because it can depend on so many factors. However, simple short-cut recommendations are generally wrong, even if a positive effect was observed in a certain special setting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 08:40:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888769#M1595599</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-12T08:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888770#M1595600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob,&lt;/P&gt;&lt;P&gt;I agree the buffering will taint the results if you are not aware, so test them one day at a time per scenario just to be sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can't say adding indexes is to be avoided. You do have to do the analysis and take into consideration which table you are having trouble with. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CPUDT is an index field on index 5, correct? So how does that help when the other fields in the WHERE clause is in another index? Not only do they need to be in the same index but they need to be in the right sequence otherwise it will not work efficiently. Dig out your BC490 courses people!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yuri and Rob, please read... I didn't say eliminating the WHERE clause. I said removing the non-indexed fields from the WHERE clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use ST05, STAD, SM50/SM66 regularly for identifying and resolving performance issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used the technique of overselecting and removing non-indexed fields from the WHERE clause with success. The difference of being able to run a report online and not. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I have implemented secondary indexes many a time at several project sites big and small. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot blanketly say "don't create secondary indexes" or "don't overselect" or "don't do loops within loops" or "don't use FOR ALL ENTRIES", etc. ANALYZE. Test it out.&lt;/P&gt;&lt;P&gt;Creating indexes tend to be a last resort, I agree, but in a case where it's needed, there's no hesitation. Siegfried, mentioned index usage depends on many&lt;/P&gt;&lt;P&gt;factors, that is why sometimes it is good to create one and other times it is not. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And as Rob said, watch out for buffering when testing but also, make sure you have data to test with. A development environment usually lacks data so &lt;/P&gt;&lt;P&gt;you need a Test or Quality environment that may be a copy of production so you have comparable volumes of data to test with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 21:53:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888770#M1595600</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-12T21:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888771#M1595601</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;Rob,&lt;/P&gt;&lt;P&gt;&amp;gt; I agree the buffering will taint the results if you are not aware, so test them one day at a time per scenario just to be sure.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; You can't say adding indexes is to be avoided. You do have to do the analysis and take into consideration which table you are having trouble with. &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; CPUDT is an index field on index 5, correct? So how does that help when the other fields in the WHERE clause is in another index? Not only do they need to be in the same index but they need to be in the right sequence otherwise it will not work efficiently. Dig out your BC490 courses people!!!&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Yuri and Rob, please read... I didn't say eliminating the WHERE clause. I said removing the non-indexed fields from the WHERE clause.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I use ST05, STAD, SM50/SM66 regularly for identifying and resolving performance issues.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I have used the technique of overselecting and removing non-indexed fields from the WHERE clause with success. The difference of being able to run a report online and not. &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; And I have implemented secondary indexes many a time at several project sites big and small. &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; You cannot blanketly say "don't create secondary indexes" or "don't overselect" or "don't do loops within loops" or "don't use FOR ALL ENTRIES", etc. ANALYZE. Test it out.&lt;/P&gt;&lt;P&gt;&amp;gt; Creating indexes tend to be a last resort, I agree, but in a case where it's needed, there's no hesitation. Siegfried, mentioned index usage depends on many&lt;/P&gt;&lt;P&gt;&amp;gt; factors, that is why sometimes it is good to create one and other times it is not. &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; And as Rob said, watch out for buffering when testing but also, make sure you have data to test with. A development environment usually lacks data so &lt;/P&gt;&lt;P&gt;&amp;gt; you need a Test or Quality environment that may be a copy of production so you have comparable volumes of data to test with.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello Filler,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do you understand the way how the database works? Please explain me here why do you think that filtering for non-indexed fields in ABAP is better than doing the same in the database.&lt;/P&gt;&lt;P&gt;I am looking forward for your explanation.&lt;/P&gt;&lt;P&gt;Don't just tell me that you have used it somewhere somewhen and you have seen positive result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am very concerned because many developers read this forum and it we start writing here things like that we (SAP) and customers are going to have problems in future.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think Siegfried's name should tell you something if you are interested in performance optimization. And he explicitly told you above: "incorrect and not recommended". I work 10 years at SAP doing 7 years performance optimization in many different areas. I also know exactly what I am talking about. Every single recommendation needs a clear explanation. I can clearly explain you why your recommendation of dropping non-indexed fields and filter in ABAP is wrong. Can you prove the opposite?&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>Fri, 13 May 2011 09:13:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888771#M1595601</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-05-13T09:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888772#M1595602</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 totally agree with Siegrfried and Yuri.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is &lt;U&gt;not recommended&lt;/U&gt; to remove non indexed fields from the WHERE condition.&lt;/P&gt;&lt;P&gt;It is wrong and not recommended. A Anti-Pattern... .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have seen this in recommendations being used as &lt;U&gt;WORKAROUNDS&lt;/U&gt; to work&lt;/P&gt;&lt;P&gt;around an optimizer problem that could not be fixed otherwise ... and when the&lt;/P&gt;&lt;P&gt;impact of the additional data selected was less... that's the only case when I tolerate it... .&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;P&gt;&lt;/P&gt;&lt;P&gt;@FILLER: you may want ot check:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://carymillsap.blogspot.com/2010/05/filter-early.html" target="test_blank"&gt;http://carymillsap.blogspot.com/2010/05/filter-early.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Hermann Gahm on May 13, 2011 1:18 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 10:10:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888772#M1595602</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2011-05-13T10:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888773#M1595603</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;Not only do they need to be in the same index but they need to be in the right sequence otherwise it will not work efficiently. Dig out your BC490 courses people!!!&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'd like to see where BC490 says that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 13:12:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888773#M1595603</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-13T13:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888774#M1595604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Filler,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wonder who you are looking for inside SAP if you got an answer by Siegfried Bu00F6s already. In the meantime also Hermann Gahm has answered. For both of them you will find an answer to who they are within SDN as well as in good bookstores. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As to Yuri: Yuri is one of our Architects in SAP Active Global Support working on performance optimization. Apparently he was not promoted to the Architect level for delivering bad optimizations. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In principle Hermanns link says it all but I will nevertheless show some measurements from one of our internal test systems. The DB is DB6 but the results can in this case be easily transferred to other Databases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I execute the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

PERFORM prepare_measurement.
PERFORM do_measurement.

FORM DO_MEASUREMENT.
  DO 5 TIMES.
    perform do_full_select.
    perform do_index_select.
  ENDDO.
ENDFORM.

FORM prepare_measurement.
  DO 3 TIMES.
    perform do_full_select.
    perform do_index_select.
  ENDDO.
ENDFORM.

FORM DO_FULL_SELECT.
  DATA:
    lt_bkpf TYPE TABLE OF bkpf.

  SELECT * FROM BKPF INTO TABLE lt_bkpf
    WHERE bukrs = '1000' AND waers = 'EUR'.
ENDFORM.

FORM DO_INDEX_SELECT.
  DATA:
    lt_bkpf TYPE TABLE OF bkpf.

  SELECT * FROM BKPF INTO TABLE lt_bkpf
    WHERE bukrs = '1000'.

  DELETE lt_bkpf WHERE waers NE 'EUR'.
ENDFORM.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ABAP Trace taken with [ST12|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/15702] &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt;; shows the following when displaying the results per modularization unit.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Form DO_MEASUREMENT
Perform DO_FULL_SELECT                 5 Executions              42,947 ms 
Perform DO_INDEX_MEASUREMENT           5 Executions              78,289 ms
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note, these numbers are now comparable since each Select was executed three times in Form PREPARE_MEASUREMENT so that the buffers in the DB are filled.&lt;/P&gt;&lt;P&gt;The SQL trace shows that the statement using only the company code in the Where clause (DO_INDEX_MEASUREMENT) returns 114620 records and uses index BKPF~BUT (MANDT, BUKRS). The other statement in which also the currency is handed to the DB (DO_FULL_MEASUREMENT) returns 61545 records and uses the same index. &lt;/P&gt;&lt;P&gt;Obviously, handing the currency to the DB accelerates the processing significantly even though the index does not contain field WAERS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why? In case of DO_FULL_MEASUREMENT the not required records are filtered out at an early stage in the database processing, i.e. when the full rows are accessed through the index. Then only the required records are sent to the ABAP. &lt;/P&gt;&lt;P&gt;In case of DO_INDEX_MEASURMENT nearly 50 % of the records are sent to ABAP in vain since they are deleted directly after the Select. But they still have to be processed further within the DB, have to be sent (possibly through the network) to the application server, they have to be processed in the database interface, they have to be stored in the internal table lt_bkpf and eventually they have to be deleted in ABAP (which took 1,045 ms for 8 executions in the trace) . And all of this takes time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the reason why it is in general recommended to put all selective fields into the Where clause. The special cases where a modified strategy needs to be pursued need expert analysis taking the technical processing (in particular in the DB) into consideration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Mathias.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mathias Uhlmann on May 13, 2011 3:41 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mathias Uhlmann on May 13, 2011 3:42 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mathias Uhlmann on May 13, 2011 3:43 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 13:40:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888774#M1595604</guid>
      <dc:creator>Mathias_Uhlmann</dc:creator>
      <dc:date>2011-05-13T13:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888775#M1595605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Yuri,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps it's your choice of words, when you say "absolutely incorrect", those are strong words, and like you say many people are reading these threads looking for answers, myself included. Thiis is why I responded, because John is not absolutly incorrect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please tell me why dropping non-indexed fields and filtering in ABAP is wrong. You said everything needs a clear explanation, but your only response to John is he is absolutely incorrect.&lt;/P&gt;&lt;P&gt;Where is the explanation part? I missed that. So then what is your recommendation to Renaldo's question?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Don't just tell me that you have used it somewhere somewhen and you have seen positive result." My "proof" is a positive result, yes. How you do prove something, when you get a negative result?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;People reading these threads are looking for what works, from other peoples experiences, they are not looking for what doesn't work, they already have that. They are looking for positive results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please provide a solution then to Reynaldo's question. I have proved my solution to myself and my clients, to prove to you, you have to test this out yourself as I suggested, on a real system with realistic volumes (millions of records).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I'm absolutely wrong on this, I guess I will have to tell my users their fixed report is imaginary and their more efficient program is not real and that they are only imagining it is not timing out and running faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please provide a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindest regards,&lt;/P&gt;&lt;P&gt;Filler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 15:09:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888775#M1595605</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-13T15:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888776#M1595606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Filler,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please read the reply from Mathias Uhlmann just above yours.&lt;/P&gt;&lt;P&gt;He has tested that on the real example.&lt;/P&gt;&lt;P&gt;Although this forum is probably not a best place for that, let me provide you a rough explanation why your approach is not working (in general).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have written something like: &lt;/P&gt;&lt;P&gt;select * from bkpf where bukrs = '1000' and waers = 'EUR'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming BUKRS is in the index, WAERS is not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following is happening:&lt;/P&gt;&lt;P&gt;1. Your request goes to DB.&lt;/P&gt;&lt;P&gt;2. Optimizer finds an index containing BUKRS field.&lt;/P&gt;&lt;P&gt;3. Index is accessed with the predicate BUKRS and relevant blocks containing a reference to the table records are found.&lt;/P&gt;&lt;P&gt;4. Table blocks are read to get the contents of the table entry&lt;/P&gt;&lt;P&gt;5. Entries that do not have WAERS = EUR are thrown away.&lt;/P&gt;&lt;P&gt;6. The rest of the entries are passed back to the SAP DB interface and written to internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what operations did we do?&lt;/P&gt;&lt;P&gt;1. Disk/buffer reads of index blocks&lt;/P&gt;&lt;P&gt;2. Disk/buffer reads of table blocks&lt;/P&gt;&lt;P&gt;3. Passing back N records (let's say 50.000 with both combinations of the BUKRS and WAERS)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your "optimization":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from bkpf where bukrs = '1000'.&lt;/P&gt;&lt;P&gt;delete from it_result where waers &amp;lt;&amp;gt; 'EUR'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following is happening:&lt;/P&gt;&lt;P&gt;1. Your request goes to DB.&lt;/P&gt;&lt;P&gt;2. Optimizer finds an index containing BUKRS field.&lt;/P&gt;&lt;P&gt;3. Index is accessed with the predicate BUKRS and relevant blocks containing a reference to the table records are found.&lt;/P&gt;&lt;P&gt;4. Table blocks are read to get the contents of the table entry&lt;/P&gt;&lt;P&gt;5. All found entries are passed back to the SAP DB interface and written to internal table&lt;/P&gt;&lt;P&gt;6. You delete entries where WAERS not equal to EUR from the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what operations did we do?&lt;/P&gt;&lt;P&gt;1. Disk/buffer reads of index blocks&lt;/P&gt;&lt;P&gt;2. Disk/buffer reads of table blocks&lt;/P&gt;&lt;P&gt;3. Passing back NN records (let's say 150.000 with BUKRS = 1000)&lt;/P&gt;&lt;P&gt;4. Deleting unnecessary entries in ABAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Compare these two actions. In the second case you are having additional overhead by transferring many unnecessary records from DB to the SAP work process, many memory operations. And expensive deletion of the unnecessary entries in ABAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This simply CANNOT be faster assuming that in both cases the same index on DB is used.&lt;/P&gt;&lt;P&gt;And if not the same index is used, then it should be solved by the optimization on the DB level (updating statistics, patches, changing indexes, etc.).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this explanation enough or you need more?&lt;/P&gt;&lt;P&gt;Mathias and Hermann already replied you with (from my PoV) detailed enough explanations why you are wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yuri&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Yuri Ziryukin on May 13, 2011 5:59 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 May 2011 15:57:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-performance/m-p/7888776#M1595606</guid>
      <dc:creator>yuri_ziryukin</dc:creator>
      <dc:date>2011-05-13T15:57:54Z</dc:date>
    </item>
  </channel>
</rss>

