首页 > 其他 > 详细

执行计划中Cardinality (Estimated Rows, E-Rows) 估算错误原因分析

时间:2014-12-31 02:16:23      阅读:324      评论:0      收藏:0      [点我收藏+]
http://structureddata.org/2007/11/21/troubleshooting-bad-execution-plans/  

1.  Data skew : NDV (Number of distinct values) inaccurate due to data skew and a poor dbms_stats sample? 
Data correlation: Are two or more predicates related to each other? 
Out-of-range values: Is the predicate within the range of known values? 
Use of functions in predicates: Is the 5% cardinality guess for functions accurate? 
Stats gathering strategies: Is your stats gathering strategy yielding representative stats?  

Some possible solutions to these issues are:  

Data skew (数据倾斜):  选择一个sample size得出正确的 NDV (Number of distinct values). 11g中使用DBMS_STATS.AUTO_SAMPLE_SIZE
                 直方图也是一个选项 。 
                 
Data correlation (数据相关):   当谓词使用多个相关列(correlated column)时,会导致约束条件的冗余。这几个相关的列也被称作关联列。
                出现这种情况时,查询优化器也可能会做出不准确的判断,在11g中可以使用 Extended Stats收集基于表达式或者一组列上
                的对象统计信息和直方图,从而解决这种问题. 如果版本<= 10.2.0.3 可以使用 CARDINALITY hint . 
                
Out-of-range values:  谓词在所知值的范围之外,需要收集或手工设置statistics。

Use of functions in predicates:   谓词中使用函数。在可能的地方使用 CARDINALITY hint 。
 
Stats gathering strategies:  数据收集策略是否产生具有代表性的统计信息。尝试使用AUTO_SAMPLE_SIZE. Adjust only where necessary. 
                         Be mindful of tables with skewed data.

执行计划中Cardinality (Estimated Rows, E-Rows) 估算错误原因分析

原文:http://blog.itpub.net/35489/viewspace-1383468/

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!