[20170612]FOR ALL COLUMNS SIZE repeat(11g).txt
[20170612]FOR ALL COLUMNS SIZE repeat(11g).txt
--//昨天看了https://jonathanlewis.wordpress.com/2017/06/01/histogram-upgrade-2/,提到了直方圖的問題,
--//特別是FOR ALL COLUMNS SIZE repeat引起的問題,在一些特殊情況要註意.
1.環境:
[email protected]> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
create table t (id number,pad varchar2(20),flag varchar2(1));
insert into t select rownum,lpad(‘a‘,20,‘a‘) ,‘a‘ from dual connect by level<=2e4;
insert into t select rownum+2e4,lpad(‘d‘,20,‘d‘) ,‘d‘ from dual connect by level<=2;
commit ;
[email protected]
F COUNT(*)
- ----------
d 2
a 20000
[email protected]> exec dbms_stats.Gather_table_stats(ownname => user, tabname => ‘T‘,method_opt => ‘FOR ALL COLUMNS ‘);
PL/SQL procedure successfully completed.
select * from DBA_TAB_COL_STATISTICS where owner=user and table_name=‘T‘ and column_name=‘FLAG‘;
Record View
As of: 2017/6/12 9:35:03
OWNER: SCOTT
TABLE_NAME: T
COLUMN_NAME: FLAG
NUM_DISTINCT: 2
LOW_VALUE: 61
HIGH_VALUE: 64
DENSITY: 0.000024997500249975
NUM_NULLS: 0
NUM_BUCKETS: 2
LAST_ANALYZED: 2017/6/12 9:33:35
SAMPLE_SIZE: 20002
GLOBAL_STATS: YES
USER_STATS: NO
AVG_COL_LEN: 2
HISTOGRAM: FREQUENCY
--//建立了直方圖.
[email protected]