Selectivity for non-pupular value in Height based Histograms.

Hi,
I wanted to check how optimizer calculates the cardinality/selectivity for a value which is not popular and histogram is height based histograms.
Following is the small test case (Version is 11.2.0.1) platform hpux
create table t1 (
       skew    not null,
       padding
as
/* with generator as (
select --+ materialize
       rownum id
from all_objects
where rownum <= 5000
select /*+ ordered use_nl(v2) */
     v1.id,
     rpad('x',400)
from
    generator  v1,
    generator v2
where
   v1.id <= 80
and
   v2.id <= 80
and
   v2.id <= v1.id
;Following is the table stats:
SQL> select count(*) from t1;
  COUNT(*)
      3240
SQL> exec dbms_stats.gather_table_stats('SYS','T1',cascade=>TRUE, estimate_percent => null, method_opt => 'for all columns size 75');
PL/SQL procedure successfully completed.
SQL> select column_name,num_distinct,density,num_buckets from dba_tab_columns where table_name='T1';
COLUMN_NAME                    NUM_DISTINCT    DENSITY NUM_BUCKETS
SKEW                                     80 .013973812          75
PADDING                                   1 .000154321           1
SQL> select endpoint_number, endpoint_value from dba_tab_histograms where column_name='SKEW' and table_name='T1' order by endpoint_number;
ENDPOINT_NUMBER ENDPOINT_VALUE
              0              1
              1              9
              2             13
              3             16
              4             19
              5             21
              6             23
              7             25
              8             26
              9             28
             10             29
ENDPOINT_NUMBER ENDPOINT_VALUE
             11             31
             12             32
             13             33
             14             35
             15             36
             16             37
             17             38
             18             39
             19             40
             20             41
             21             42
ENDPOINT_NUMBER ENDPOINT_VALUE
             22             43
             23             44
             24             45
             25             46
             26             47
             27             48
             28             49
             29             50
             30             51
             32             52
             33             53
ENDPOINT_NUMBER ENDPOINT_VALUE
             34             54
             35             55
             37             56
             38             57
             39             58
             41             59
             42             60
             43             61
             45             62
             46             63
             48             64
ENDPOINT_NUMBER ENDPOINT_VALUE
             49             65
             51             66
             52             67
             54             68
             56             69
             57             70
             59             71
             60             72
             62             73
             64             74
             66             75
ENDPOINT_NUMBER ENDPOINT_VALUE
             67             76
             69             77
             71             78
             73             79
             75             80
60 rows selected.Checking the selectivity for value 75(which is the popular value as per information from dba_tab_histograms
SQL> set autotrace on
SQL> select count(*) from t1 where skew=75;
  COUNT(*)
        75
Execution Plan
Plan hash value: 4273422929
| Id  | Operation         | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |       |     1 |     3 |     1   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE   |       |     1 |     3 |            |          |
|*  2 |   INDEX RANGE SCAN| T1_I1 |    86 |   258 |     1   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - access("SKEW"=75)Skipped the Statistics information for keep example short.
selectivity for 75 (popular value) = 2/75 = 0.02666
Cardinality for 75 is = selectivity * num_rows = 0.02666*3240 = 86.3784 (rounded to 86) >> Here selectivity and cardinality are correct and displayed in autotrace.
SQL> select count(*) from t1 where skew=8;
  COUNT(*)
         8
Execution Plan
Plan hash value: 4273422929
| Id  | Operation         | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |       |     1 |     3 |     1   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE   |       |     1 |     3 |            |          |
|*  2 |   INDEX RANGE SCAN| T1_I1 |    29 |    87 |     1   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - access("SKEW"=8)how the cardinality is 29 calculated. I think the formula for selectivity is
select for 1(non popular value) = density * num_rows = .013973812 * num_rows (which is 45 approx) but in autotrace its 29
SQL> select count(*) from t1 where skew = 46;
  COUNT(*)
        46
Execution Plan
Plan hash value: 4273422929
| Id  | Operation         | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |       |     1 |     3 |     1   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE   |       |     1 |     3 |            |          |
|*  2 |   INDEX RANGE SCAN| T1_I1 |    29 |    87 |     1   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - access("SKEW"=46)46 is also non popular value
So how the value is calculated for these values?

Your example seems to be based on Jonathan Lewis's article:
http://jonathanlewis.wordpress.com/2012/01/03/newdensity/
In this article, he does walk through the calculation of selectivity for non-popular values.
The calculation is not density but NewDensity, as seen in a 10053 trace, which takes into account the number of non-popular values AND the number of non-popular buckets
The article describes exactly how 29 is derived.Hi Dom,
Yes i used the same sample script of create the data sets. I should have checked Jonathan's blog for new density calculations. So selectivity works out as two either ways
1) selectivity(non popular) = Newdensity(took from 10053 traces) * rum_rows
or
2) non-popular rows/ non_popular values (where non-popular values can be derived from 10053 traces and non popular rows are (3240 * (74-31)/74 = ) 1883
Thanks for pointing to right blog

Similar Messages

  • "initial non-cumulative for non-cumulative values"  is not available in DTP (0AFMM_C02)

    Hi Experts,
    We are working for BI implementation for AFS Industry,
    when we are working on AFS specific inventory cube 0AFMM_C02 , we are facing stock mismatch problem
    for AFS Stock initialization we are using the data source 2LIS_AF_STOCK_INITALIZATION instead of 2LIS_03_BX, this data source is specificly designed for AFS
    when we are extracting the data using 2LIS_AF_STOCK_INITALIZATION for stock initialization and
    2LIS_03_BF data source to load the Moments.
    we compressed cube with Marker update for 2LIS_AF_STOCK_INITALIZATION data load(by deselecting the No marker update check box)
    we compressed cube with No Marker update for 2LIS_03_BF historical data load(by selecting the No marker update check box)
    we compressed cube with Marker update for 2LIS_03_BF Delta data load(by deselecting the No marker update check box)
    Now we are facing stock mistach problem, we found reason for this
    "initial non-cumulative for non-cumulative values" option is not available in DTP only Delta & Full options are available
    and infopackage of  2LIS_AF_STOCK_INITALIZATION data source also has "Full update" instead of "Generate Intial Status"
    Please let us know how can we get the "initial non-cumulative for non-cumulative values" option in the DTP level.
    Regards,
    Chandra

    Hi Chandrakumar,
    We are facing the same problem, how do you solve it?
    Regards,

  • Application hangs for non existing value

    Hi,
    At the DB level I tried to query non existing value from the table, query came out with "no rows selected" . But when I try to do the same from front end, application hangs! I just checked in the statspack report it shows like query is taking more cpu time to execute. what could be the reason for this?
    when I join the v$session,v$sql to get the currently running query on database, it shows the query which try to execute from the application as active.
    why it is hanging in application and why not in DB?
    can any one brief me on this regard? why does application hangs for non exsting value?
    With Regards
    Boo

    Hi,
    At the DB level I tried to query non existing value from the table, query came out with "no rows selected" . But when I try to do the same from front end, application hangs! I just checked in the statspack report it shows like query is taking more cpu time to execute. what could be the reason for this?
    when I join the v$session,v$sql to get the currently running query on database, it shows the query which try to execute from the application as active.
    why it is hanging in application and why not in DB?
    can any one brief me on this regard? why does application hangs for non exsting value?
    With Regards
    Boo

  • How can I reduce the selection for the characteristics value in a BW query

    Good morning,
    I need to find out how I can reduce the selection for the characteristics values in a BW query.
    In a BW query I have a characteristic "Due month".
    The characteristic values shown in the query are from 01.2001->03.2007. I would like to reduce it to the last 2 years,in the query view,  without deleting the data for the other years in the cube.
    Do you know how this can be done?
    Thank you in advance for your feedback.
    Kind regards,
    Linda Verding
    Staff Consultant - CSC

    hi,
    First thing you have to do is check the report how the data is being restricted only to those months.
    1) one it can be variable in which the code is written for that to populate for last few years.
    or else it must have been hardcoded for these months.
    Go into your report and underneath the characteristicsCALMONTH there must be an variable or hardcoding.
    You need to change this here in the report.
    You dont have to delete anything there.
    Regards, Siva

  • Display Non-zero values of keyfigures based on a particular value of a char

    Hi Gurus,
    I would like to display only Non-zero values for keyfigures but only for a particular value of a characteristic. For Ex: We have material Group. For a particular value of material group, i do not want to display the zero stock. But for other material groups it should display zero stock.
    I tried to use conditions, but the problem is it suppresses all the zero values for the keyfigure for material group in general and not for a particular value of the material group.
    Is there is any way that i can go about for this scenario. Pls help.
    thanks & regards,
    PS

    Hi
    Create a structure in the rows based on selections on material group. Eg.
    Structure
       Mat grp 1 (restricted to material during selection)
       Mat grp 2
    then add a formula in columns using boolean argument
    e.g (exisisting KF >= 1)*1+0
    Then you can use conditions to elimanate zeros on the new KF.
    Hope it helps
    Edited by: Karin van der Merwe on Feb 29, 2008 8:52 AM

  • Display Non-zero values of keyfigures based on a particular value of a cha

    Hi Gurus,
    I would like to display only Non-zero values for keyfigures but only for a particular value of a characteristic. For Ex: We have material Group. For a particular value of material group, i do not want to display the zero stock. But for other material groups it should display zero stock.
    I tried to use conditions, but the problem is it suppresses all the zero values for the keyfigure for material group in general and not for a particular value of the material group.
    Is there is any way that i can go about for this scenario. Pls help.
    thanks & regards,
    PS

    Hi,
    You can very much restrict your KF on particular values of said material group. For example you material group contains the values like "Blades", "Personal Cares", "Disposables" etc... and you want to restrict your KF on "Blades" only, you can do that.
    Just restrict your KF on Material Group and include the values which you want for restrictions. You can also exclude values from restrictions.
    Hope it help you.
    Yogesh.

  • How to find average for non blank values

    I need to calculate avarage for each restricted key figures. There are some blank values in this restricted key figures. Now I need to sumup and divide by non blank count. Do you know how to do it? How to count non blnak values and find avereage.
    Thanks,
    Phani

    In the properties of Key figure used in column/row, Calculations section, you can maintain calculation type for result as well as single value. There is "Average of all values not equal 0" option is available.
    Rgds,
    Vikram.
    Edited by: Vikram Kate on May 22, 2008 11:23 AM

  • How to load init for non cumulative values?

    Hi folks,
    anyone here, who can tell me how to load initial amounts from DSO to non cumulative values in InfoCubes?
    I found only poor documentation about this.
    Thanks!

    hi Timo
    you load initial of load as you do in the normal case only thing you have to keep in mind that before loading opening balance you have to UNCLICK  NO MARKER UPDATE from the infocube and compress the request ASAP as it will greatly effect your query performance.
    sanjeev

  • Hi, I have a problem. I'm 14 years of age and obviously I don't have a credit card. And you you need one for iTunes / apple ID the only problem is I don't have a selection for none. All I want to do is download some free apps so please help me

    Hi, I'm 14 years of age girl with no credit card and I just want to download free apps help!!'

    Why can’t I select None when I edit my payment information?
    Create a NEW account/ID for her using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before. Make sure you specify a birthdate that results in being at least 13 years old
      Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    More details of how:
    http://ipadhelp.com/ipad-help-tips-tricks/how-to-get-free-apps-from-the-app-stor e-without-a-credit-card/

  • SQL Challenge - Returning count=0 for non-existing values

    Hello there,
    I have a question about our requirement and an SQL query. I have posted this to some email groups but got no answer yet.
    Here is the test case:
    SQL> conn ...
    Connected.
    -- create the pattern table and populate
    SQL> create table pattern(id number, keydescription varchar2(50));
    Table created.
    SQL> insert into pattern values(1,'hata1');
    1 row created.
    SQL> insert into pattern values(2,'hata2');
    1 row created.
    SQL> insert into pattern values(3,'hata3');
    1 row created.
    SQL> insert into pattern values(4,'hata4');
    1 row created.
    SQL> insert into pattern values(5,'hata5');
    1 row created.
    SQL> select * from pattern;
    ID KEYDESCRIPTION
    1 hata1
    2 hata2
    3 hata3
    4 hata4
    5 hata5
    SQL> commit;
    Commit complete.
    -- create the messagetrack and populate
    SQL> create table messagetrack(pattern_id number, realdate date);
    Table created.
    SQL> insert into messagetrack values(1,to_date('26/08/2007 13:00:00','dd/mm/yyyy hh24:MI:ss'));
    1 row created.
    SQL> insert into messagetrack values(1,to_date('26/08/2007 13:05:00','dd/mm/yyyy hh24:MI:ss'));
    1 row created.
    SQL> insert into messagetrack values(2,to_date('26/08/2007 13:15:00','dd/mm/yyyy hh24:MI:ss'));
    1 row created.
    SQL> insert into messagetrack values(3,to_date('26/08/2007 14:15:00','dd/mm/yyyy hh24:MI:ss'));
    1 row created.
    SQL> insert into messagetrack values(4,to_date('26/08/2007 15:15:00','dd/mm/yyyy hh24:MI:ss'));
    1 row created.
    SQL> insert into messagetrack values(1,to_date('26/08/2007 15:15:00','dd/mm/yyyy hh24:MI:ss'));
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from messagetrack;
    PATTERN_ID REALDATE
    1 26-AUG-07
    1 26-AUG-07
    2 26-AUG-07
    3 26-AUG-07
    4 26-AUG-07
    1 26-AUG-07
    6 rows selected.
    Now, we have this simple query:
    SQL> select p.KeyDescription as rptBase , to_char( mt.realdate,'dd') as P1 , to_char(mt.realdate,'HH24') as P2, count(*) as countX
    2 from messageTrack mt, Pattern p
    3 Where mt.realDate >= to_date('26/08/2007 13:00:00','dd/MM/yyyy hh24:MI:ss')
    4 and mt.realDate <= to_date('27/08/2007 20:00:00','dd/MM/yyyy hh24:MI:ss')
    5 and mt.pattern_id=p.id
    6 group by p.KeyDescription, to_char(mt.realdate,'dd'), to_char( mt.realdate,'HH24')
    7 order by p.KeyDescription, to_char(mt.realdate,'dd'), to_char(mt.realdate,'HH24');
    RPTBASE P1 P2 COUNTX
    hata1 26 13 2
    hata1 26 15 1
    hata2 26 13 1
    hata3 26 14 1
    hata4 26 15 1
    But the result we need should contain the pattern values(hata1, hata2, hata3 and hata4) for each time interval(hour) although there are might be no records of some patterns for some hours.
    The result for our test case should look like this:
    RPTBASE P1 P2 COUNTX
    hata1 26 13 2
    hata1 26 14 0
    hata1 26 15 0
    hata2 26 13 1
    hata2 26 14 0
    hata2 26 15 0
    hata3 26 13 0
    hata3 26 14 1
    hata3 26 15 0
    hata4 26 13 0
    hata4 26 14 0
    hata4 26 15 1
    Our version is 10.2.0.2
    On my discussions some said model clause may be used, but i don't know model clause much and can't imagine how to use.
    You can download the test case code above to reproduce from:
    http://www.bhatipoglu.com/files/query1.txt
    You can see the output above more clearly(monospace font) on:
    http://www.bhatipoglu.com/files/query1_output.txt
    Additionally, I want to state that, in the resulting table, we don't want all the patterns(hata1, hata2, hata3, hata4 and hata5). We just want the ones that exists on messageTrack table(hata1, hata2, hata3 and hata4) as you see on the result.
    Thanks in advance.

    Here is an attempt with the Model Clause:
    Edit: I should mention that I created a view out of your original query.
    SELECT rptbase
          ,day
          ,hour
          ,countx
    FROM demoV
      MODEL
        DIMENSION BY (rptbase, day, hour)
        MEASURES (countx)
          RULES(countx[
                        FOR rptbase IN (SELECT rptbase
                                        FROM demoV)
                        ,FOR day IN   (SELECT day
                                        FROM demoV)
                        ,FOR hour FROM 13 to 15 INCREMENT 1
                        ] =
                        NVL(countx[CV(rptbase),CV(day),CV(hour)],0)
                order by 1,2,3;Which produces the following
    RPTBASE                                    DAY                 HOUR               COUNTX                
    hata1                                              26                     13                     2                     
    hata1                                              26                     14                     0                     
    hata1                                              26                     15                     1                     
    hata2                                              26                     13                     1                     
    hata2                                              26                     14                     0                     
    hata2                                              26                     15                     0                     
    hata3                                              26                     13                     0                     
    hata3                                              26                     14                     1                     
    hata3                                              26                     15                     0                     
    hata4                                              26                     13                     0                     
    hata4                                              26                     14                     0                     
    hata4                                              26                     15                     1               Note my Hata1 26 15 has a countx of 1 (I believe that this is correct and that your sample result is incorrect, if this is not the case, please explain why it should be 0)
    Message was edited by:
    JS1

  • Dynamic Selection for non-logical database

    How to read the dynamic selections information to a table that is not in logical database for ex. : BSAD.
    Currently, i'm reading from the function module 'RS_REFRESH_FROM_DYNAMICAL_SEL'. The value for the fields are read one by one...........totalling to thousands of codes.
    Does anyone noe a shorter way of reading it ?
    Please give sme guidance. Thank you.

    Hi Mr Anthony,
    I have a report using logical database. However, the logical database used does not contain a table, BSEG, which i need to access.
    I understand that for tables which are not in the logical database, I cannot use the "GET <tablename>" in the "START_OF_SELECTION" event.
    Please advise on how to use the "SELECT" statement for the BSEG table with constraints from the dynamic selections. Thank you

  • Coding for Non cumulative values

    Hi
    I have scenario like this. I have a objects called Work in progress(WIP) and cost of sales. ( COS) both are differentated by General Ledger.
    Like 400025, 4000026, 400027 are WIP.
           500000,5000001, 50006 are COS.
    if working porgress is booked on 05/05/08 and for thatWIP order if  COS is booked on 08/05/08, then we need to reverse the WIP on 08/05/08. means when COS is booked that time we need to reverse the WIP.
    as a solution i am thing of using non cumulative keyfigures for WIP. when it is booked it is Inflow and when COS is entered it is Outflow.
    logic is if
    Confirmation item(CI),confirmation item number (CITN) of WIP GL is matching with CI,CITN of COS GL then it we need to write to OUTFLOW.
    IFNOT
    it is INFLOW.
    now can some body give me a sample code to derive this Inflow and out flow.
    Thanks

    Hi Chandrakumar,
    We are facing the same problem, how do you solve it?
    Regards,

  • Non-Cumulative value Infoset will not work

    Why doesn't an Infoset work with non-cumaltive values? Can I just use a multiprovider to get around this issue?

    Hi,
       Non cumulative values are not stored anywhere in the database. These are just definitions which are calculated at runtime. Consider the Stock cube. It has 2 key figures. Received stock and issued stock. It also has a Non cumulative Kf total stock which is defined as inflow : Received stock and outflow : issued stock.
    At Query runtime, the total stock is calculated as inflow - outflow. No data is physically stored in your database.
    Since an infoset joins values stored in a database, you will not be able to use it for Non cumulative values.
    What you can do is find your Non cumulative KF definition, and map the input fields for this KF. You can then try and use these fields to calculate the value as a formula.
    Hope this helps.
    Regards.

  • Non-numeric values in analog I/O points

    I have a system with a FP-3000 controller and a series of TC-120 and RLY-420 modules. At various times I am receiving erros for non-numeric values in some of the analog I/O points. The value, as stated by Ni-FIBUS is "-1.#IND".
    Does any one know what this is? Also once this value appears, It is impossible to get rid of it. The function must be completely deleted and re made from scratch.

    Some general suggestions:
    1. Settings of Function Blocks do not match the real input values, such as type mismatch. You need to verify the value data and type.
    2. Invalid Scaling settings, the units of parameters between connecting function blocks may not match. Please check the block input and output.

  • Search help for a field in table control based on another field value

    Hi,
    I want to attach the Search help for a field in table control based on another field value.
    Please help me asap.
    Will be highly rewarded

    HI,..
      Check these links
    search help in table control
    Re: How to create Search Help for a field in Table control !!
    How to create Search Help for a field in Table control !!
    F4 Help In Table Control
    Control table F4 help
    Problem in F4 help in screen field
    check this code
    DATA: BEGIN OF it_value4 OCCURS 0,
             TEXTCODE  LIKE  ZXX-TEXTCODE,
             TEXTDESC  LIKE  ZXX-TEXTDESC,
           END OF it_value4.
      progname = sy-repid.
      dynnum   = sy-dynnr.
             SELECT TEXTCODE TEXTDESC
               FROM  xxxx
               INTO CORRESPONDING FIELDS OF TABLE<b> it_value4</b>
              WHERE  LOSS_CODE =<b> IT_VALUE1 .</b>
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield    = 'TEXTCODE'
          dynpprog    = progname
          dynpnr      = dynnum
          dynprofield = 'ITVALUE-TEXTCODE'  "-->UR  4 th filed value in screen
          value_org   = 'S'
        TABLES
          value_tab   = it_value4.
    endmodule.
    Message was edited by:
            veereshbabu ponnada

Maybe you are looking for

  • CAM_ERROR while creating a Business Partner using SD_CUSTOMER_MAINTAIN_ALL

    Hello All, I was trying to create a Business Partner(Ship to Party) using function module SD_CUSTOMER_MAINTAIN_ALL. When I am executing this through SE37 transaction, its working fine & creating a KUNNR value along with new ADRNR number. But when the

  • Business Partner replication from ECC to CRM based on Company code

    Hi: I got this requirement where we need to transfer customers from ECC --> CRM. Customers specific to a company code. Trying to maintain Filters for  CUSTOMER_main--> KNB1- BUKRS to filter customers by a certain company code.  I get this error " Tab

  • Explanation of some code samples

    Hello, can you explain me some code samples? First: try{ wdContext.currentBapi_Flight_Getlist_InputElement(). modelObject().execute(); catch (Exception ex){ ex.printStackTrace(); wdContext.nodeOutput().invalidate(); Second: Bapi_Flight_Getlist_Input

  • SE 38 Program

    Hi Folks,   It will be much helpful ,if anyone of us share the SE38 programs names and its Corresponding uses. Will assign points to all helpful answers

  • Managing ODI Agent through OPMN - Install Issue

    Hi I am attempting to set up my ODI agent so that I can manage it through my OPMN service but I keep getting an error "java is not recognised as an internal or external command, operable program or batch file" when I run the command "odi_opmn_addagen