[20170612]FOR ALL COLUMNS SIZE repeat(12c).txt
[20170612]FOR ALL COLUMNS SIZE repeat(12c).txt
--//昨天看了https://jonathanlewis.wordpress.com/2017/06/01/histogram-upgrade-2/,提到了直方圖的問題,
--//特別是FOR ALL COLUMNS SIZE repeat引起的問題,在一些特殊情況要註意.
1.環境:
[email protected]> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- ---------------------------------------------------------------------------- ------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
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]
PL/SQL procedure successfully completed.
[email protected]> SELECT flag, COUNT(*) FROM t GROUP BY flag;
F COUNT(*)
- ----------
d 2
a 20000
select * from DBA_TAB_COL_STATISTICS where owner=user and table_name=‘T‘ and column_name=‘FLAG‘;
Record View
As of: 2017/6/12 20:38:56
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 20:37:55
SAMPLE_SIZE: 20002
GLOBAL_STATS: YES
USER_STATS: NO
NOTES:
AVG_COL_LEN: 2
HISTOGRAM: FREQUENCY
SCOPE: SHARED
--//建立了直方圖.bucket=2.
[email protected]