Oracle 12c新特性 - Hybrid histogram 1

tolywang發表於2014-03-24

1.  建立一個表test_tmp3

CODE COUNT(1)
------  --------
1    2
2    2
3    100
4    20
5    1
6    54
7    2
8    2
9    5
10   1
11   2
12   1

注:  資料共 192 行


2.  生成 Hybrid Histogram 的必要條件: 

1).  n is less than the NDV, where n is the user-specified number of buckets. If no number is specified, then n defaults to 254.
2).  The criteria for top frequency histograms do not apply. See "Criteria For Frequency Histograms."
3).  The sampling percentage is AUTO_SAMPLE_SIZE.

If users specify their own percentage, then the database creates frequency or height-balanced histograms.


由算術公式可以計算出,什麼情況下在1,3條件滿足時不會生成 top frequency histogram ,會生成 Hybrid Histogram .

1 - 1/n > 187/192    (187 是表在bucket =8的情況下 個數排在前八位[top 8]的所有值的個數,這個公式反過來是  top frequency histogram生成的條件,詳見 http://blog.itpub.net/35489/viewspace-1128170/ ) 
n < 12                (12是不同值個數)

發現n沒有解,看來這樣的列(CODE)只能生成 top frequency histogram 。 從公式可以看出,想要生成hybrid histogram,  n 要儘量大,且資料總行數儘量大,而要n

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-1128177/,如需轉載,請註明出處,否則將追究法律責任。

相關文章