|
原帖由 Yong Huang 于 2009-3-31 02:01 发表 ![]()
I see what you mean. I did give some thought to this. Let's see if we can conclude this way.
The "table" selectivity we talked about is probably indeed single partition's selectivity (let's call it PS). So the whole table's selectivity is TS=PS*#partitions. This means that given any key in index, the probability to find the table block having this key in the whole table is TS, and that to find it in one of the partitions is PS. OK?
Yes
Now the "第三部分中CF*(table selectivity)here really is PS, not TS.". It should be changed to CF * PS, not CF * TS. Note that PS is TS/#partitions, so this cost is (CF*TS)/#partitions. This last expression answers your question, doesn't it? It says give me all blocks in the entire table that have all the index keys (CF), out of those give me those that meet the probability of table selectivity (CF*TS), and out of those give me only one of all partitions (assuming there's no data skew).
It should be changed to CF * TS, not CF * PS. Note that TS is PS/#partitions, so this cost is (CF*PS)/#partitions.
By the way, have you noticed ix_sel (index selectivity) and ix_sel_with_filters ("table" selectivity; drop the quotation marks if the table is not partitioned) usually are the same or very close? In your case the former is 3.4 times as large as the latter. How many partitions do you have? 25? I don't know how to explain this value 3.4. I thought it was related to the number of partitions.
Yong Huang
我认为ix_sel和ix_sel_with_filter之所以不同是因为索引字段中的from_date,to_date,在查询条件中是不等值的,而对于不等值查询条件,索引中的后续条件将无法用到,就这个查询而言to_date将用不到,而只是作为来filter体现。
[ 本帖最后由 必有我师 于 2009-3-31 13:25 编辑 ] |
|