在计算selectivity 中,有如下描述:
We have been using the basic formula for the selectivity of a range-based predicate, and know that this varies slightly depending on whether you have zero, one, or two closed (meaning the equality in=) ends to your range. UsingNas the number of closed ends, the version of the formula that usesuser_tab_columns.num_distinctcan be written as
(required range) / (column high value - column low value) + N / num_distinct
For example, in a column with 1,000 different (integer) values ranging from 1 to 1000, and the pair of predicatescolX > 10andcolX =1 这是就有两个closed end;N 就取2.
而 在(required range) / (column high value - column low value) 之后, 又加了个N / num_distinct, 显然是 在优化器没有柱状图统计信息时, 假设了 数据的均匀分布; 但 如果假设了 数据的均匀分布前面又为什么没有使用 requied range/num_distinct 呢?
是我的推理出现了什么问题吗?
|