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/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/35489/viewspace-1128177/