https://hourim.wordpress.com/?s=histogram

https://jonathanlewis.wordpress.com/2013/10/09/12c-histograms-pt-3/

exec dbms_stats.delete_table_stats('SYS','T1');


exec dbms_stats.gather_table_stats(user,'T1', method_opt=>'for columns size 20 col1');

exec dbms_stats.gather_table_stats(user,'T1', method_opt=>'for all columns size 1');



select
        endpoint_number,
        endpoint_value,
        endpoint_repeat_count
from
        user_tab_histograms
where
        table_name = 'T1'
order by
        endpoint_number
;


set pages 50 lines 256

alter system flush shared_pool;

drop table Q purge;

create table Q as
   select /*+ GATHER_PLAN_STATISTICS */
       a.COL1    COL1
   from
       T1 a,
       T1 b
   where
     a.COL1=b.COL1
   /

select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST  +PEEKED_BINDS +PARALLEL +PARTITION +COST +BYTES'));


set pages 50 lines 256

alter system flush shared_pool;

drop table Q purge;

create table Q as
   select /*+ GATHER_PLAN_STATISTICS */
       a.COL1    COL1
   from
       T1 a,
       T1 b
   where
     a.COL1=33 and
     a.COL1=b.COL1
   /

select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST  +PEEKED_BINDS +PARALLEL +PARTITION +COST +BYTES'));




set pages 50 lines 256

alter system flush shared_pool;

drop table Q purge;

create table Q as
   select /*+ GATHER_PLAN_STATISTICS */
       a.COL1    COL1
   from
       T1 a,
       T1 b
   where
     a.COL1=37 and
     a.COL1=b.COL1
   /

select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST  +PEEKED_BINDS +PARALLEL +PARTITION +COST +BYTES'));



37 distinct values - 20 popular values = 17 non popular values
On 32 lines => 17 non popular values (oniform distributed) => 2 lines / value



x    17      



