<?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: Column(s) selectivity in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910178#M1329629</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui Dantas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the ST05 popup in the bottom there should be a button "index statistics".&lt;/P&gt;&lt;P&gt;These values are interesting for both indexes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the basic problem is that the optimizer assumes that WERKS and MATNR&lt;/P&gt;&lt;P&gt;are not correlated. But in your database there is some correlation between&lt;/P&gt;&lt;P&gt;those two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle 9i: Correlations are not considered at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle 10.2.0.2: Correlations are only considered for the index access&lt;/P&gt;&lt;P&gt;by taking into account the distinct keys of the index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle 10.2.0.4: Correlations are considered using dynamic sampling&lt;/P&gt;&lt;P&gt;and simplified column group statistics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle 11g: General column group statistics are available&lt;/P&gt;&lt;P&gt;(independent of existing indexes).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what to do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's not easy and i don't know if there is a real good solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i did in the past was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- hint&lt;/P&gt;&lt;P&gt;- patch the satistics (e.g. make CHARG more attractive (more distinct values))&lt;/P&gt;&lt;P&gt;- some self made optimization in abap (evaluate where and hint in special cases)&lt;/P&gt;&lt;P&gt;- substitute values and histograms&lt;/P&gt;&lt;P&gt;- recomend an upgrade from 10.2.0.2 to 10.2.0.4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;each thing has pros- and cons- ... sorry &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&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, 17 Jul 2009 16:52:54 GMT</pubDate>
    <dc:creator>HermannGahm</dc:creator>
    <dc:date>2009-07-17T16:52:54Z</dc:date>
    <item>
      <title>Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910174#M1329625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;2 questions (not really sure if it's against the rules to pose two questions in one post, but here they go):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 1&lt;/STRONG&gt;: We have in MSEG one index by CHARG (MSEG&lt;SUB&gt;Z01) and another one by WERKS + MATNR (MSEG&lt;/SUB&gt;M)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(statistics 100%)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;nr rows: 24,991,486
matnr:      225,480     
werks:           90
charg:    6,882,957&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CHARG is in fact more selective than MATNR + WERKS, &lt;/P&gt;&lt;P&gt;even if &lt;EM&gt;nr distinct values charg&lt;/EM&gt; &amp;lt; &lt;EM&gt;nr distinct values werks&lt;/EM&gt; x &lt;EM&gt;nr distinct values matnr&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;(because in reality each material appears only in 1 or 2 plants)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following query, then, uses MSEG&lt;SUB&gt;M and not MSEG&lt;/SUB&gt;Z01 (which would be faster). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select *
from   mseg 
where  mandt = :a1
and    werks = :a2
and    matnr = :a3
and    charg = :a4&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Apart from using hints (I don't want to force Z01 because the report has other optional parameters, and if filled other indexes should be selected), any ideas on how this is usually solved? For now the solution we have is to not use WERKS in the where condition (and then CHARG is more selective than MATNR, and Z01 is used).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 2&lt;/STRONG&gt;: In our MSEG, the density for CHARG is not 1/distinct values (and that happens, I think, because we have MSEG with histograms - don't ask me why, but we do). Question is, how is this density calculated?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select table_name, column_name, num_distinct, 1/num_distinct, density, num_buckets
from   all_tab_columns
where  table_name = 'MSEG'
and   column_name = 'CHARG'

TABLE_NAME                     COLUMN_NAME                    NUM_DISTINCT 1/NUM_DISTINCT    DENSITY NUM_BUCKETS
------------------------------ ------------------------------ ------------ -------------- ---------- -----------
MSEG                           CHARG                               6882957     1,4529E-07 ,000115903          61&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I saw somewhere that the formula would be&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sum(count^2) / ( sum(count)^2 )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but that doesn't seem to produce the expected density:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select sum(sq) / (sum(cnt) * sum(cnt))
from ( select charg, count(*)*count(*) sq, count(*) cnt from sapr3.mseg group by charg )

SUM(SQ)/(SUM(CNT)*SUM(CNT))
---------------------------
                 ,038637666&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2009 14:18:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910174#M1329625</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2009-07-17T14:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910175#M1329626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui Dantas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for 1:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you post your index statistics, please?&lt;/P&gt;&lt;P&gt;i assume both indexes contain client as first field?&lt;/P&gt;&lt;P&gt;starting with 10g distinct keys  (index statistic) plays an important role.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Furthermore you probably don't want to use subsitute values, right? (which could make a change)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Furthermore i found out that  in10.2.0.4 distinct keys are not only relvant for index selectivty but for&lt;/P&gt;&lt;P&gt;talbe selectivty as well which makes a change as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And as always, make sure you have set the current parameter recommendations for your db &lt;/P&gt;&lt;P&gt;(use the attached sql in  note 1171650  for an automated Oracle DB parameter check)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for 2:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what i found in the net somewhere:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;density = u03A3 cnt2 / ( num_rowsu02DC * u03A3 cnt )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u201Cthe sum of the squared frequencies of all non-popular values divided by the&lt;/P&gt;&lt;P&gt;sum of the frequencies of all non-popular values times the count of rows&lt;/P&gt;&lt;P&gt;with not null values of the histogram columnu201D.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But i didn't found a definition for "frequencies of all non-popular values"... &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and another update:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The calculation of density in case of a histogram is documented in the US &lt;/P&gt;&lt;P&gt;patent 6732085:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freepatentsonline.com/6732085.html" target="test_blank"&gt;http://www.freepatentsonline.com/6732085.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&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;Edited by: Hermann Gahm on Jul 17, 2009 5:16 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2009 15:02:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910175#M1329626</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2009-07-17T15:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910176#M1329627</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;&lt;STRONG&gt;for 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i use 9.2.&lt;/P&gt;&lt;P&gt;i am not exactly sure what info you are asking me, but:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;NONUNIQUE  Index   MSEG~Z01                     

Column Name                     #Distinct       
CHARG                                  6,882,957
                                                                                NONUNIQUE  Index   MSEG~M                       
                                                
Column Name                     #Distinct                                                      
MANDT                                          1
MATNR                                    225,480
WERKS                                         90
LGORT                                        694
BWART                                        152
SOBKZ                                          7&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, there are in fact some things I ommited to make it simpler:&lt;/P&gt;&lt;P&gt;- MSEG~M has MANDT (but only 1 distinct value, so it shouldn't make a difference)&lt;/P&gt;&lt;P&gt;- MSEG~M has other fields (after the 3 we use, so it shouldn't make a difference)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand that the selectivity for two fields (in this case MATNR + WERKS) is the product of the selectivity of each field, so it is expected that it is higher than CHARG alone. The problem is that in reality selectivity (matnr + werks) is much lower than selectivity (matnr) * selectivity (werks), because all materials do not exist in all plants. &lt;/P&gt;&lt;P&gt;I suppose this is a frequent problem for db optimization (and cause of wrong cost estimation), so that's why I was asking what is usually done in these situations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;for 2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;i also thought just after posting that I would have to remove the popular values, because they are problably not used in the calculation of the average density. I'll check if there are popular values in this table's histograms, and also look more carefully to your formula, which seems different from what I had found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2009 15:27:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910176#M1329627</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2009-07-17T15:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910177#M1329628</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 with you to do not force an index.&lt;/P&gt;&lt;P&gt;Try use substitute values hint as Hermann suggested.&lt;/P&gt;&lt;P&gt;With the values probably the optimizer will choose your Z01 index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%_HINTS ORACLE '&amp;amp;SUBSTITUTE VALUES&amp;amp;'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Fernando Da Ró&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2009 15:31:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910177#M1329628</guid>
      <dc:creator>former_member182114</dc:creator>
      <dc:date>2009-07-17T15:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910178#M1329629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui Dantas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the ST05 popup in the bottom there should be a button "index statistics".&lt;/P&gt;&lt;P&gt;These values are interesting for both indexes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the basic problem is that the optimizer assumes that WERKS and MATNR&lt;/P&gt;&lt;P&gt;are not correlated. But in your database there is some correlation between&lt;/P&gt;&lt;P&gt;those two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle 9i: Correlations are not considered at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle 10.2.0.2: Correlations are only considered for the index access&lt;/P&gt;&lt;P&gt;by taking into account the distinct keys of the index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle 10.2.0.4: Correlations are considered using dynamic sampling&lt;/P&gt;&lt;P&gt;and simplified column group statistics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oracle 11g: General column group statistics are available&lt;/P&gt;&lt;P&gt;(independent of existing indexes).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So what to do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's not easy and i don't know if there is a real good solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i did in the past was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- hint&lt;/P&gt;&lt;P&gt;- patch the satistics (e.g. make CHARG more attractive (more distinct values))&lt;/P&gt;&lt;P&gt;- some self made optimization in abap (evaluate where and hint in special cases)&lt;/P&gt;&lt;P&gt;- substitute values and histograms&lt;/P&gt;&lt;P&gt;- recomend an upgrade from 10.2.0.2 to 10.2.0.4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;each thing has pros- and cons- ... sorry &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&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, 17 Jul 2009 16:52:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910178#M1329629</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2009-07-17T16:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910179#M1329630</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;Perfect, thanks. The abap dynamic thing is what we've been doing; I guess I'll have to wait for 10g for further improvements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way, about your "patch statistics" solution: to avoid this value being overwritten every time statistics are calculated, can I "freeze" only that column, or would I have to lock the whole table against stat updates (like is done, for example, in oss note 1020260)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The index statistics:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NONUNIQUE  Index   MSEG~Z01                                                                     &lt;/P&gt;&lt;P&gt;Last statistics date                  2009-07-11&lt;/P&gt;&lt;P&gt;Analyze Method              mple 24,991,486 Rows&lt;/P&gt;&lt;P&gt;Levels of B-Tree                               2&lt;/P&gt;&lt;P&gt;Number of leaf blocks                     93,802&lt;/P&gt;&lt;P&gt;Number of distinct keys                6,882,957&lt;/P&gt;&lt;P&gt;Average leaf blocks per key                    1&lt;/P&gt;&lt;P&gt;Average data blocks per key                    2&lt;/P&gt;&lt;P&gt;Clustering factor                     18,991,009&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NONUNIQUE  Index   MSEG~M      &lt;/P&gt;&lt;P&gt;Last statistics date                  2009-07-11&lt;/P&gt;&lt;P&gt;Analyze Method              mple 24,991,486 Rows&lt;/P&gt;&lt;P&gt;Levels of B-Tree                               3&lt;/P&gt;&lt;P&gt;Number of leaf blocks                    183,363&lt;/P&gt;&lt;P&gt;Number of distinct keys                  872,451&lt;/P&gt;&lt;P&gt;Average leaf blocks per key                    1&lt;/P&gt;&lt;P&gt;Average data blocks per key                   19&lt;/P&gt;&lt;P&gt;Clustering factor                     16,626,875&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, thanks a lot for the expert tips.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2009 17:30:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910179#M1329630</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2009-07-17T17:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910180#M1329631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rui Dantas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the statistics. The distinct keys are there but not used for cost calculation in 9i.&lt;/P&gt;&lt;P&gt;In 10g the selectivity would be: min(distinct(MATNR) * distinct(WERKS) ; distinct key of that index) or something&lt;/P&gt;&lt;P&gt;like that... . but i'm not sure if with binds and histograms density will still be used for selectivity... . Maybe you&lt;/P&gt;&lt;P&gt;can try to adjust the density of that column... .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ORACLE 9 you can only lock the table in DBSTATC (that is SAP level and brtools evaluate it). On DB level&lt;/P&gt;&lt;P&gt;the stats are not locked and can be overwritten in ORACLE 9i. In ORACLE 10g one can lock statistics at&lt;/P&gt;&lt;P&gt;DB level. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, wait for 10g... you'll enjoy... &lt;/P&gt;&lt;P&gt;-much more fun and things to do with new features... solutions for old problems... and new problems...&lt;/P&gt;&lt;P&gt;and new methods to approach them... &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&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>Sat, 18 Jul 2009 06:45:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910180#M1329631</guid>
      <dc:creator>HermannGahm</dc:creator>
      <dc:date>2009-07-18T06:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910181#M1329632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should also remember that one seldom goes against MSEG directly.&lt;/P&gt;&lt;P&gt;If you cannot restrict the access through MSKPF (? parent) you should look at the number of index tables (4 to 6? 8?)&lt;/P&gt;&lt;P&gt;This way you can access a restricted set of keys that will give you the right information to access MSEG by key, or not at all if the information you need is already in one of the index tables...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have fun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jul 2009 10:03:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910181#M1329632</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-19T10:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910182#M1329633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the index Z01 is your index, then you could change that index, why don't you add werks or matnr as an additional field?&lt;/P&gt;&lt;P&gt;WERKS is short.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jul 2009 13:21:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910182#M1329633</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-19T13:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910183#M1329634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="16" __jive_macro_name="size"&gt;???&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 08:21:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910183#M1329634</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-20T08:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Column(s) selectivity</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910184#M1329635</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;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi Rui,&lt;/P&gt;&lt;P&gt;&amp;gt; Try use substitute values hint as Hermann suggested.&lt;/P&gt;&lt;P&gt;&amp;gt; With the values probably the optimizer will choose your Z01 index.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;CODE&gt;%_HINTS ORACLE '&amp;amp;SUBSTITUTE VALUES&amp;amp;'&lt;/CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUBSTITUTE VALUES is more difficult to test to know for sure (because in some cases Z01 would be used and not in others), but I would say the problem would still be there (oracle doesn't know the correlation between the two fields), so it would still wrongly estimate the number of rows. Anyway I would rather not use SUBSTITUTE VALUES.&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; If the index Z01 is your index, then you could change that index, why don't you add werks or matnr as an additional field?&lt;/P&gt;&lt;P&gt;&amp;gt; WERKS is short.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yep, well thought, werks would solve the problem. MSEG~Z01 is already around 600 Mb only with CHARG, so I was hoping not to have to make it bigger, but thanks for the suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, I consider the 1st part of the question answered with the correlations thing in 10g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the 2nd part, I still haven't found the time to test the formula, but I'll get there soon.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jul 2009 15:21:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/column-s-selectivity/m-p/5910184#M1329635</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2009-07-22T15:21:13Z</dc:date>
    </item>
  </channel>
</rss>

