<?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: Indexes making program run slower... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334140#M1538586</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't have the full details on this PC, but I can tell you it only uses Z03. ( The indexes were created for another process, but were interfering with this one ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Oct 2010 09:47:00 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2010-10-12T09:47:00Z</dc:date>
    <item>
      <title>Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334128#M1538574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With the indexes, the program runs more slowly, much more slowly than when the indexes aren't there. However, the explain function to me indicates that with the indexes, it should be much better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The explain when the indexes are present is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SQL Statement
------------------------------------------------------------------------
SELECT
  T_01 . "MANDT" , T_01 . "VBELN" , T_01 . "VFDAT" , T_02 . "BUKRS" ,
  T_00 . "VKORG" ,   T_02 . "VKORG" , T_00 . "VBELN" , T_03 . "BUKRS"
FROM
 "LIPS" T_01 INNER JOIN "LIKP" T_00 ON T_01 . "MANDT" = :A0 AND T_00 . "VBELN" = T_01 . "VBELN"
  INNER JOIN "TVKO" T_02 ON T_02 . "MANDT" = :A1 AND T_00 . "VKORG" = T_02 . "VKORG" INNER JOIN "T9F
  ATLAS_CCO" T_03   ON T_03 . "MANDT" = :A2 AND T_02 . "BUKRS" = T_03 . "BUKRS"
WHERE
  T_00 . "MANDT" = :A3 AND ( T_01 . "ERDAT" &amp;lt;= :A4 OR T_01 . "AEDAT" &amp;lt;= :A5 )   AND ( ( T_01 .
  "ERDAT" &amp;gt;= :A6 OR T_01 . "AEDAT" &amp;lt;= :A7 )                        AND ( ( T_01 .   "ERDAT" &amp;lt;= :A8
  OR T_01 . "AEDAT" &amp;gt;= :A9 )                        AND ( T_01 . "ERDAT" &amp;gt;= :A10 OR   T_01 .
  "AEDAT" &amp;gt;= :A11 ) ) )


Execution Plan

--------------------------------------------------------------------------------------
| Id  | Operation                       | Name           | Rows  | Bytes | Cost (%CPU)|
---------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                |                |  4632 |  1248K| 73711   (3)|
|   1 |  CONCATENATION                  |                |       |       |            |
|   2 |   NESTED LOOPS                  |                |  2375 |   640K| 41855   (3)|
|*  3 |    HASH JOIN                    |                |  2375 |   619K| 41854   (3)|
|*  4 |     TABLE ACCESS FULL           | TVKO           |    59 |   826 |     2   (0)|
|   5 |     NESTED LOOPS                |                |  2558 |   632K| 41851   (3)|
|*  6 |      TABLE ACCESS BY INDEX ROWID| LIPS           |  2558 |   582K| 40814   (3)|
|*  7 |       INDEX RANGE SCAN          | LIPS~Z04       |   496K|       |   492   (7)|
|   8 |      TABLE ACCESS BY INDEX ROWID| LIKP           |     1 |    20 |     0   (0)|
|*  9 |       INDEX UNIQUE SCAN         | LIKP~0         |     1 |       |     0   (0)|
|* 10 |    INDEX UNIQUE SCAN            | T9FATLAS_CCO~0 |     1 |     9 |     0   (0)|
|  11 |   NESTED LOOPS                  |                |  2257 |   608K| 31856   (4)|
|* 12 |    HASH JOIN                    |                |  2257 |   588K| 31856   (4)|
|* 13 |     TABLE ACCESS FULL           | TVKO           |    59 |   826 |     2   (0)|
|  14 |     NESTED LOOPS                |                |  2430 |   600K| 31853   (4)|
|* 15 |      TABLE ACCESS BY INDEX ROWID| LIPS           |  2430 |   552K| 30868   (4)|
|* 16 |       INDEX RANGE SCAN          | LIPS~Z03       |   496K|       |   495   (7)|
|  17 |      TABLE ACCESS BY INDEX ROWID| LIKP           |     1 |    20 |     0   (0)|
|* 18 |       INDEX UNIQUE SCAN         | LIKP~0         |     1 |       |     0   (0)|
|* 19 |    INDEX UNIQUE SCAN            | T9FATLAS_CCO~0 |     1 |     9 |     0   (0)|
-----------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - access("T_00"."VKORG"="T_02"."VKORG")
   4 - filter("T_02"."MANDT"=:A1)
   6 - filter(("T_01"."ERDAT"&amp;gt;=:A6 OR "T_01"."AEDAT"&amp;lt;=:A7) AND
              ("T_01"."ERDAT"&amp;lt;=:A8 OR "T_01"."AEDAT"&amp;gt;=:A9) AND ("T_01"."ERDAT"&amp;gt;=:A10 OR
              "T_01"."AEDAT"&amp;gt;=:A11))
   7 - access("T_01"."MANDT"=:A0 AND "T_01"."AEDAT"&amp;lt;=:A5)
   9 - access("T_00"."MANDT"=:A3 AND "T_00"."VBELN"="T_01"."VBELN")
  10 - access("T_03"."MANDT"=:A2 AND "T_02"."BUKRS"="T_03"."BUKRS")
  12 - access("T_00"."VKORG"="T_02"."VKORG")
  13 - filter("T_02"."MANDT"=:A1)
  15 - filter(("T_01"."ERDAT"&amp;gt;=:A10 OR "T_01"."AEDAT"&amp;gt;=:A11) AND
              ("T_01"."ERDAT"&amp;lt;=:A8 OR "T_01"."AEDAT"&amp;gt;=:A9) AND ("T_01"."ERDAT"&amp;gt;=:A6 OR
              "T_01"."AEDAT"&amp;lt;=:A7) AND LNNVL("T_01"."AEDAT"&amp;lt;=:A5))
  16 - access("T_01"."MANDT"=:A0 AND "T_01"."ERDAT"&amp;lt;=:A4)
  18 - access("T_00"."MANDT"=:A3 AND "T_00"."VBELN"="T_01"."VBELN")
  19 - access("T_03"."MANDT"=:A2 AND "T_02"."BUKRS"="T_03"."BUKRS")
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2010 18:45:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334128#M1538574</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-10-07T18:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334129#M1538575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

--------------------------------------------------------------------------------------
| Id  | Operation                      | Name           | Rows  | Bytes | Cost (%CPU)|
--------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |                |  5168 |  1392K|  1019K (27)|
|*  1 |  HASH JOIN                     |                |  5168 |  1392K|  1019K (27)|
|*  2 |   INDEX RANGE SCAN             | T9FATLAS_CCO~0 |   146 |  1314 |     0   (0)|
|*  3 |   HASH JOIN                    |                |  5168 |  1347K|  1019K (27)|
|*  4 |    TABLE ACCESS FULL           | TVKO           |    57 |   798 |     2   (0)|
|   5 |    NESTED LOOPS                |                |  5622 |  1389K|  1019K (27)|
|*  6 |     TABLE ACCESS FULL          | LIPS           |  5622 |  1279K|  1016K (27)|
|   7 |     TABLE ACCESS BY INDEX ROWID| LIKP           |     1 |    20 |     0   (0)|
|*  8 |      INDEX UNIQUE SCAN         | LIKP~0         |     1 |       |     0   (0)|
--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - access("T_02"."BUKRS"="T_03"."BUKRS")
   2 - access("T_03"."MANDT"=:A2)
   3 - access("T_00"."VKORG"="T_02"."VKORG")
   4 - filter("T_02"."MANDT"=:A1)
   6 - filter(("T_01"."ERDAT"&amp;lt;=:A4 OR "T_01"."AEDAT"&amp;lt;=:A5) AND
              ("T_01"."ERDAT"&amp;gt;=:A6 OR "T_01"."AEDAT"&amp;lt;=:A7) AND ("T_01"."ERDAT"&amp;lt;=:A8 OR
              "T_01"."AEDAT"&amp;gt;=:A9) AND ("T_01"."ERDAT"&amp;gt;=:A10 OR "T_01"."AEDAT"&amp;gt;=:A11) AND
              "T_01"."MANDT"=:A0)
   8 - access("T_00"."MANDT"=:A3 AND "T_00"."VBELN"="T_01"."VBELN")
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried using the explain when the indexes are present via ST04, with hint "NO_INDEX" and with "FULL("LIPS") but the indexes get used anyway.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ABAP Is generated...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is: am I right in thinking that according to the EXPLAIN, the program &lt;EM&gt;should&lt;/EM&gt; be running faster with the indexes?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2010 18:46:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334129#M1538575</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-10-07T18:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334130#M1538576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; I've tried using the explain when the indexes are present via ST04, with hint "NO_INDEX" and with "FULL("LIPS") but the indexes get used anyway.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; My question is: am I right in thinking that according to the EXPLAIN, the program &lt;EM&gt;should&lt;/EM&gt; be running faster with the indexes?.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; matt&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the hints in ST04 you must use the alias, so for example FULL (T_01). In ABAP you would use &amp;amp;TABLE 2&amp;amp;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle tries to estimate the cost, but of course this is an &lt;EM&gt;estimation&lt;/EM&gt;. For example, when you do AEDAT &amp;lt;= :A5 he will probably estimate that 5% of the records are returned (you can confirm that if you check how many rows are in LIPS, and how many rows he is estimating in that step), but if AEDAT is a recent date a much higher percentage of rows will be returned. This higher percentage of rows means that a FULL actually performs better (because you can read directly the table in an optimized way, instead of the index and then the table repeatedly for every row returned from the index).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps in any way,&lt;/P&gt;&lt;P&gt;Rui Dantas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Oct 2010 10:00:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334130#M1538576</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-10-08T10:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334131#M1538577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as Rui already explained almost correctly (the AEDAT &amp;lt;= :A5  is MAX(0.009, 1 / NUM_DISTINCT(column) % ... &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt; )  the &lt;/P&gt;&lt;P&gt;optimizer estimates. With this estimations the like, &amp;lt;, &amp;gt;, between and correlations and other things can be a problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With a complex query like this, i would use the gather_plan_statistics:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this site or google for "gather_plan_statistics"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://kerryosborne.oracle-guy.com/2010/02/gather_plan_statistics/" target="test_blank"&gt;http://kerryosborne.oracle-guy.com/2010/02/gather_plan_statistics/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the sql command editor for running the statement with the hint and the&lt;/P&gt;&lt;P&gt;actual parameters and the statements for getting the plan statistics&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each step in the plan you get then &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;estimated rows (e-rows)&lt;/P&gt;&lt;P&gt;actual rows (a-rows)&lt;/P&gt;&lt;P&gt;actual time (a-time)&lt;/P&gt;&lt;P&gt;actual buffer gets&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with this information you can see where the optimizers estimations are close or far away&lt;/P&gt;&lt;P&gt;from the realitiy. it should bring you directly to that step in the plan that causes the long&lt;/P&gt;&lt;P&gt;run time....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&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, 08 Oct 2010 16:21:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334131#M1538577</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-10-08T16:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334132#M1538578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; as Rui already explained almost correctly (the AEDAT &amp;lt;= :A5  is MAX(0.009, 1 / NUM_DISTINCT(column) % ... &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt; ) ...&lt;/P&gt;&lt;P&gt;&amp;gt; Hermann&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Hermann,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't mention the &lt;EM&gt;1 / NUM_DISTINCT&lt;/EM&gt; part because it did not seem relevant for a field like AEDAT, but I was curious about your 0.009 figure. These magic numbers are configurable, or?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my system I get 5%:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LIPS: 5,425,703 Rows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM lips WHERE aedat &amp;lt;= :a1      

SELECT STATEMENT ( Estimated Costs = 126,053 , Estimated #Rows = 271,285 ) 
       1 TABLE ACCESS FULL LIPS 
         ( Estim. Costs = 126,053 , Estim. #Rows = 271,285 ) 
         Estim. CPU-Costs = 16,885,467,271 Estim. IO-Costs = 123,329&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Oct 13, 2010 4:11 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Oct 2010 09:58:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334132#M1538578</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-10-11T09:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334133#M1538579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you are right:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The estimation for &lt;U&gt;rows returned&lt;/U&gt;  for AEDAT &amp;lt;= :A5  is 5 % (can not be changed).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The estimation for the filter factor in &lt;U&gt;cost estimations&lt;/U&gt; however is FF = max(0.009, 1 / NDV(column))&lt;/P&gt;&lt;P&gt;as described in note 750631. The 0.009 can not be changed as well (as far as i know).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But no matter which one we choose the estimations (cost or rows) for &amp;lt;=, &amp;gt;=, or between ... and (&amp;lt;= or &amp;gt;=)&lt;/P&gt;&lt;P&gt;is very often too optmistic and can lead to wrong decisions quite often.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW: that's why they called it OPTImizer, because it's OPTImistic and calculates with OPTImal circumstances.&lt;/P&gt;&lt;P&gt;If it would be PESSImisitic... they would have named it PESSImizer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Things get worse if we have ABAP developers who try to specify all fields in an index where we often see&lt;/P&gt;&lt;P&gt;where condions like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;AND field BETWEEN &amp;lt;minval&amp;gt; AND &amp;lt;maxval&amp;gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;AND field &amp;gt;= &amp;lt;minval&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the optimizer is really off with the estimations (a small amount of rows, costs estimated but everything is selected).&lt;/P&gt;&lt;P&gt;Surpressing these conditions can lead to better estimations and more efficient plans. We have seen this quite often.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Coming back to Matt's problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;looking at the filters.... each &amp;lt;= or &amp;gt;= uses a OPTImistic estimations for rows and even more OPTImistic estimation&lt;/P&gt;&lt;P&gt;for the cost (filter factors for index accesses). These estimations are combined e.g. for the rows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0,5 * 0,5 * 0,5 ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; 6 - filter(("T_01"."ERDAT"&amp;lt;=:A4 OR "T_01"."AEDAT"&amp;lt;=:A5) &lt;/P&gt;&lt;P&gt;AND       ("T_01"."ERDAT"&amp;gt;=:A6 OR "T_01"."AEDAT"&amp;lt;=:A7) &lt;/P&gt;&lt;P&gt;AND      ("T_01"."ERDAT"&amp;lt;=:A8 OR  "T_01"."AEDAT"&amp;gt;=:A9) &lt;/P&gt;&lt;P&gt;AND      ("T_01"."ERDAT"&amp;gt;=:A10 OR "T_01"."AEDAT"&amp;gt;=:A11) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the end we have a &lt;U&gt;very&lt;/U&gt; optimistic estimation for rows and cost.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the actual content is not as selective as the optimizer estimates (which is often the case)&lt;/P&gt;&lt;P&gt;we might get a plan which would be efficient for very small result sets but at the same time&lt;/P&gt;&lt;P&gt;is inefficient for bigger result sets.... .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The execution plan with the indexes would be optmial if the actual amount of rows would&lt;/P&gt;&lt;P&gt;match the optimizers expectations... .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regars,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Oct 2010 11:12:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334133#M1538579</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-10-11T11:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334134#M1538580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;small example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table T100 has 918007 rows in my system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from t100 where msgnr &amp;gt;= :a0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MSGNR is a field with Message Numbers for Application Areas and Languages.&lt;/P&gt;&lt;P&gt;It's a 3 character field and we have many '001's and '002's and so on and some&lt;/P&gt;&lt;P&gt;'999's and even some real characters (in my system). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the default installtion we have 2 indexes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Primary Key:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SPRSL, ARGB, MSGNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inex 001&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ARBGB, MSGNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the distintct keys are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SPRSL 9&lt;/P&gt;&lt;P&gt;ARBGB 5703&lt;/P&gt;&lt;P&gt;MSGNR 1190&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An index skip scan is no alternative here so we get a full table scan.&lt;/P&gt;&lt;P&gt;The optimizer estimates 5 % of the rows being returned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i would now create an index on MSGNR the optimizer would pick it&lt;/P&gt;&lt;P&gt;up since we have a selective field (1190 distinct keys and  5 % rows&lt;/P&gt;&lt;P&gt;estimation is pretty selective, istn't it? (The cost estimation for that&lt;/P&gt;&lt;P&gt;index range scan would even be better!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If run the query with a value that returns 5 % or less of the data &lt;/P&gt;&lt;P&gt;e.g. where msgnr &amp;gt;= '850' or somthing like that&lt;/P&gt;&lt;P&gt;the execution is technically efficient and quite fast....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what if i would run it with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; where msgnr &amp;gt;= '000'  or  where msgnr &amp;gt;= '200'  &lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt; where msgnr &amp;gt;= '000'  and msgnr &amp;lt;= '999' (between)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we would still use the index (same estimations), but read almost all index blocks&lt;/P&gt;&lt;P&gt;AND almost all table blocks and many of them several times (depends on the clustering factor).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The query would be much slower in this case although the execution&lt;/P&gt;&lt;P&gt;plan and cost estimation looks nice. One could assume that it should&lt;/P&gt;&lt;P&gt;run faster but in cases where the estimation of the optimizer does not&lt;/P&gt;&lt;P&gt;match the real world (optimizer assumes good selectivity for these ranges&lt;/P&gt;&lt;P&gt;but they are not as selective) it doesn't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@ MATT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, yes, in some cases, creating an index can make execution plans look better and slow&lt;/P&gt;&lt;P&gt;down the response time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to check the selectivity of your &amp;gt;= and &amp;lt;= predicates and compare the estimations of&lt;/P&gt;&lt;P&gt;the optimizer with the reality, either manually or automated with gather_plan_statistics.&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>Mon, 11 Oct 2010 11:44:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334134#M1538580</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-10-11T11:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334135#M1538581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hermann,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&amp;gt; The estimation for &lt;U&gt;rows returned&lt;/U&gt;  for AEDAT &amp;lt;= :A5  is 5 % (can not be changed).&lt;/P&gt;&lt;P&gt;&amp;gt; The estimation for the filter factor in &lt;U&gt;cost estimations&lt;/U&gt; however is FF = max(0.009, 1 / NDV(column))&lt;/P&gt;&lt;P&gt;&amp;gt; as described in note 750631. The 0.009 can not be changed as well (as far as i know).&lt;/P&gt;&lt;P&gt;&amp;gt; Hermann&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Great, thanks. Note 750631 explains well the different between filtter factor (FF, used for the cost estimation) and row filter factor (RFF, used for the estimations of number of rows), and in which special occasions they differ (one being this &amp;lt;= case). I confess I mostly look at the number of rows, because it is a "real" number, and so easier to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt; &amp;gt; BTW: that's why they called it OPTImizer, because it's OPTImistic and calculates with OPTImal circumstances.&lt;/P&gt;&lt;P&gt;&amp;gt; If it would be PESSImisitic... they would have named it PESSImizer.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I like this definition.. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;but... with this &amp;lt; or &amp;gt; cases I find that it often works a a PESSImizer. Where I work I get to approve what is installed in production, so those &amp;gt;= minvalue would not be installed in the first place. But... you often have things like "all records created in the last day", so you get &amp;gt;= almost_the_max_value, and in that case 5% ends up being a too pessimistic choice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matt,&lt;/P&gt;&lt;P&gt;Sorry if this has gone into a somewhat different discussion but from what I saw from you in the past I would guess you wouldn't mind. &lt;/P&gt;&lt;P&gt;The conditions in your where clause seem quite confusing to me without knowing which ABAP variables are behind those placeholders. Maybe you could share the ABAP code, or I suppose you better than noone will know if (or which of) the conditions are really selective and which are things like &amp;gt;= minvalue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rui Dantas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Oct 2010 13:36:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334135#M1538581</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-10-11T13:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334136#M1538582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i agree that the estimated rows are easier to understand. And sometimes are even&lt;/P&gt;&lt;P&gt;more important than estimated costs e.g. if we talk about joins (how often does&lt;/P&gt;&lt;P&gt;the inner table has to be accessed?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regarding the "all records created in the last day" and &amp;gt;= almost_the_max_value&lt;/P&gt;&lt;P&gt;is that "almost_the_max_value" included in the statistics? Or ist the max value in the&lt;/P&gt;&lt;P&gt;statistics less than the queried "&amp;gt;= almost_the_max_value"? In such a case where&lt;/P&gt;&lt;P&gt;the max value in the stats is let's say 100 and we look for &amp;gt;=109 and the real max&lt;/P&gt;&lt;P&gt;value is 110 (but no up to date statistics) the predicate is out of bound or out of range&lt;/P&gt;&lt;P&gt;and the optimizer should use a different calculation. I don't have the details only&lt;/P&gt;&lt;P&gt;this quote from the net:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; "The optimizer prorates the selectivity based on the distance between the &lt;/P&gt;&lt;P&gt;predicate value and the maximum value (assuming the value is higher than the max), &lt;/P&gt;&lt;P&gt;that is, the farther the value is from the maximum value, the lower the selectivity will be."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or let me ask differently: Did you got wrong decisions because the estimation was&lt;/P&gt;&lt;P&gt;too negative? I rarely have seen such cases so far. The wrong decisions i have seen&lt;/P&gt;&lt;P&gt;were usually based on too optmistic estimates.&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>Mon, 11 Oct 2010 15:34:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334136#M1538582</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-10-11T15:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334137#M1538583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;would you mind to give the information:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) how many blocks for table LIPS&lt;/P&gt;&lt;P&gt;2) how many rows for table LIPS&lt;/P&gt;&lt;P&gt;3) how many rows for LIPS and your selection criteria:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
WHERE
  T_00 . "MANDT" = :A3 
AND (   T_01 ."ERDAT" &amp;lt;= :A4  OR T_01 . "AEDAT" &amp;lt;= :A5 )   
AND (     ( T_01 ."ERDAT" &amp;gt;= :A6  OR T_01 . "AEDAT" &amp;lt;= :A7 ) 
      AND (     ( T_01 ."ERDAT" &amp;lt;= :A8  OR T_01 . "AEDAT" &amp;gt;= :A9 ) 
            AND ( T_01 ."ERDAT" &amp;gt;= :A10 OR   T_01 .  "AEDAT" &amp;gt;= :A11 ) 
          )
    )
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What fields did you use in your index?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: Oh, and can you give the fieldvalues as well pleas?&lt;/P&gt;&lt;P&gt;Esp. if there are duplicates, like :A7 equals :A5 in ABAP source&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Volker&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Volker Borowski on Oct 11, 2010 8:22 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Oct 2010 18:16:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334137#M1538583</guid>
      <dc:creator>volker_borowski2</dc:creator>
      <dc:date>2010-10-11T18:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334138#M1538584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The original ABAP sql (generated by ACTA) is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WHERE ( ( ( LIPS9~ERDAT &amp;lt;= $PARAM2 ) OR ( LIPS9~AEDAT &amp;lt;= $PARAM2 ) )
 AND ( ( ( LIPS9~ERDAT &amp;gt;= $PARAM1 ) OR ( LIPS9~AEDAT &amp;lt;= $PARAM2 ) )
 AND ( ( ( LIPS9~ERDAT &amp;lt;= $PARAM2 )  OR ( LIPS9~AEDAT &amp;gt;= $PARAM1 ) )
 AND ( ( LIPS9~ERDAT &amp;gt;= $PARAM1 ) OR ( LIPS9~AEDAT &amp;gt;= $PARAM1 ) ) ) ) ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which simplifies to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WHERE ( LIPS9~ERDAT &amp;lt;= $PARAM2 OR LIPS9~AEDAT &amp;lt;= $PARAM2 ) 
  AND ( LIPS9~ERDAT &amp;gt;= $PARAM1 OR LIPS9~AEDAT &amp;lt;= $PARAM2 )
  AND ( LIPS9~ERDAT &amp;lt;= $PARAM2 OR LIPS9~AEDAT &amp;gt;= $PARAM1 )
  AND ( LIPS9~ERDAT &amp;gt;= $PARAM1 OR LIPS9~AEDAT &amp;gt;= $PARAM1 ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, $PARAM1 &amp;lt;= $PARAM2, and I think it's safe to say that ERDAT &amp;lt;= AEDAT. So the selection is looking for any documents that changed or were created between $PARAM1 and $PARAM2. And that simplifies to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LIPS9~ERDAT &amp;lt;= $PARAM2 AND ( LIPS9~AEDAT &amp;lt;= $PARAM2 OR LIPS9~ERDAT &amp;gt;= $PARAM1 ) AND LIPS9~AEDAT &amp;gt;= $PARAM1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've shoved that through the EXPLAIN, and get encouraging results. I've now passed the info onto the ACTA team, who are going to look at redoing their selection to generate this simpler WHERE clause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 08:45:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334138#M1538584</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-10-12T08:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334139#M1538585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just out of curiosity, what explain do you have now?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand correctly you have an index Z03 by ERDAT and a Z04 by AEDAT.&lt;/P&gt;&lt;P&gt;I would try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;( erdat between $PARAM1 and $PARAM2 ) or ( aedat between $PARAM1 and $PARAM2 )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That should make two index scans (one using Z03 and another one using Z04) and then concatenate the results. If the interval (difference between $PARAM1 and $PARAM2) is small enough I would say that is your best bet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rui&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 09:35:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334139#M1538585</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-10-12T09:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334140#M1538586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't have the full details on this PC, but I can tell you it only uses Z03. ( The indexes were created for another process, but were interfering with this one ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 09:47:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334140#M1538586</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-10-12T09:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334141#M1538587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; I don't have the full details on this PC, but I can tell you it only uses Z03. ( The indexes were created for another process, but were interfering with this one ).&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; matt&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;You said the final goal is "changed &lt;EM&gt;or&lt;/EM&gt; were created between $PARAM1 and $PARAM2". &lt;/P&gt;&lt;P&gt;Something that was &lt;STRONG&gt;changed&lt;/STRONG&gt; (AEDAT) between $PARAM1 and $PARAM2 might have been &lt;EM&gt;created&lt;/EM&gt; anywhere in time, so an access only by ERDAT is never enough (you'll have to use a FULL for the rest, or maybe another index access). That's why I think, and since you have both indexes, that they both should be used, and then the results concatenated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rui&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 09:57:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334141#M1538587</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-10-12T09:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334142#M1538588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have no system to check right now, and I am not familiar with this LIPS table, but what happens to "several" changes?&lt;/P&gt;&lt;P&gt;Might be need to go for changedocuments ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I.E. what would this situation been like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
ERDAT   20090103  AEDAT   20090107
P1      20090104  P2      20090105

whith a change on 20090105 AND 20090107 ???
Assuming AEDAT holds the date of the "last" change
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this situation it evaluates to "false" allthough there was a change on 20090105.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, if the logical Expression goes ok, it might be worth to check the worth of one descending index field,&lt;/P&gt;&lt;P&gt;depending on which field covers the bigger/lower range.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So &lt;/P&gt;&lt;P&gt;MANDT&lt;EM&gt;ERDAT&lt;/EM&gt;AEDAT look like the obvious choice (and are creatable in DDIC), but &lt;/P&gt;&lt;P&gt;MANDT&lt;EM&gt;ERDAT&lt;/EM&gt;AEDAT DESC&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;MANDT&lt;EM&gt;AEDAT&lt;/EM&gt;ERDAT DESC&lt;/P&gt;&lt;P&gt;might be real boosters depending on data distribution and average PARAM1 / PARAM2 values &lt;/P&gt;&lt;P&gt;(but are only creatable on DB level allthough I never understood why, because the correspondig &lt;/P&gt;&lt;P&gt;DDIC-table from SAP has a tag for using a descending field).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards &lt;/P&gt;&lt;P&gt;Volker&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Oct 2010 16:57:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334142#M1538588</guid>
      <dc:creator>volker_borowski2</dc:creator>
      <dc:date>2010-10-12T16:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334143#M1538589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Volker,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Anyway, if the logical Expression goes ok, it might be worth to check the worth of one descending index field,&lt;/P&gt;&lt;P&gt;&amp;gt; depending on which field covers the bigger/lower range.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; So &lt;/P&gt;&lt;P&gt;&amp;gt; MANDT&lt;EM&gt;ERDAT&lt;/EM&gt;AEDAT look like the obvious choice (and are creatable in DDIC), but &lt;/P&gt;&lt;P&gt;&amp;gt; MANDT&lt;EM&gt;ERDAT&lt;/EM&gt;AEDAT DESC&lt;/P&gt;&lt;P&gt;&amp;gt; or&lt;/P&gt;&lt;P&gt;&amp;gt; MANDT&lt;EM&gt;AEDAT&lt;/EM&gt;ERDAT DESC&lt;/P&gt;&lt;P&gt;&amp;gt; might be real boosters depending on data distribution and average PARAM1 / PARAM2 values &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sounds interesting. Could you give more details in which circumstances this could be beneficial for&lt;/P&gt;&lt;P&gt;performance (as long as we don't talk about an order by which could benefit from a corresponding order &lt;/P&gt;&lt;P&gt;in an index)? I've never seen descending indexes beeing used for queury tuning so far, so i would be&lt;/P&gt;&lt;P&gt;interested in which case and how it could help for performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; (but are only creatable on DB level allthough I never understood why, because the correspondig &lt;/P&gt;&lt;P&gt;&amp;gt; DDIC-table from SAP has a tag for using a descending field).&lt;/P&gt;&lt;P&gt;I guess that not all db plattforms supported by SAP support descending index columns (or didn't &lt;/P&gt;&lt;P&gt;support them in the past)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hermann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 08:23:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334143#M1538589</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-10-13T08:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334144#M1538590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hermann,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not like to hijack Matt's thread for a detailed description, so just the assets:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The basic idea is to make a range scan on index leaf blocks shorter &lt;/P&gt;&lt;P&gt;because your hitting the "interesting" records earlier and can abort the range scan&lt;/P&gt;&lt;P&gt;after the "interesting" records instead of "overreading" "uninteresting" records in an ascending scan&lt;/P&gt;&lt;P&gt;first and useless before you reach the "interesting" records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is rarely benefitial in direct table access (because Oracle knows "range scan descending" on standard indexes) &lt;/P&gt;&lt;P&gt;but it can be quite ok if your "&amp;gt;" is only a small number of rows (i.e. the first of 300 possible ones) &lt;/P&gt;&lt;P&gt;and the optimizer does not consider the descending scan because more than one field has the "&amp;gt;" condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And it can be a real booster in a nested loop join, because you have this benefit for each record joined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this gives some kind of insight&lt;/P&gt;&lt;P&gt;Volker&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 18:20:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334144#M1538590</guid>
      <dc:creator>volker_borowski2</dc:creator>
      <dc:date>2010-10-13T18:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334145#M1538591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I love you hijacking my thread - I find all this stuff really interesting. If my moderator colleagues agree, I'll reference this thread in the intros and memorable discussions sticky thread.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 19:41:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334145#M1538591</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2010-10-13T19:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334146#M1538592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good idea!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 20:17:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334146#M1538592</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-13T20:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Indexes making program run slower...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334147#M1538593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Volker,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks. My missing piece was this one:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; It is rarely benefitial in direct table access (because Oracle knows "range scan descending" on standard indexes) &lt;/P&gt;&lt;P&gt;&amp;gt; but it can be quite ok if your "&amp;gt;" is only a small number of rows (i.e. the first of 300 possible ones) &lt;/P&gt;&lt;P&gt;&amp;gt; and the optimizer does not consider the descending scan because more than one field has the "&amp;gt;" condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my first thought was, since we have "range scan descending" and double linked lists in the leafs (we can go forth &lt;U&gt;and back&lt;/U&gt; ) i was wondering why we would like to store a column in descending order for performance reasons. It sounded somehow superfluous. The missing piece was, if the optimizer does not use the descending scan and sticks to the ascending one, the effoet in scanning the leafs could indeed be shorter if the interesting records come first. So thanks for that hint.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have seen people using "sorting tables" (reorganize or IOT) to get a better clustering of interesting rows but never descending indexes so far... but it fits in this scenario as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Matt, in case you try it, could you let us know your results please?&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, 14 Oct 2010 07:15:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/indexes-making-program-run-slower/m-p/7334147#M1538593</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2010-10-14T07:15:11Z</dc:date>
    </item>
  </channel>
</rss>

