ORACLE统计抽样默认比例
oracle 统计 默认抽样还是全表扫描?默认DBMS_STATS.AUTO_SAMPLE_SIZE自动化
官方文档
Sampling is specified using the ESTIMATE_PERCENT argument to the DBMS_STATS procedures. While you can set the sampling percentage to any value, Oracle recommends setting the ESTIMATE_PERCENT parameter of the DBMS_STATS gathering procedures to DBMS_STATS.AUTO_SAMPLE_SIZE to maximize performance gains while achieving necessary statistical accuracy. AUTO_SAMPLE_SIZE lets Oracle Database determine the best sample size necessary for good statistics, based on the statistical property of the object. Because each type of statistics has different requirements, the size of the actual sample taken may not be the same across the table, columns, or indexes. For example, to collect table and column statistics for all tables in the OE schema with auto-sampling, you could use:
总结:
1. 9i中ESTIMATE_PERCENT默认100%。
2. 10g中ESTIMATE_PERCENT默认为DBMS_STATS.AUTO_SAMPLE_SIZE,一个非常非常小的数,通常会造成poor的统计信息,因此并不建议使用AUTO。
3. 11g中ESTIMATE_PERCENT默认为DBMS_STATS.AUTO_SAMPLE_SIZE,但由于其采用了一种新的HASH算法,即使倾向于默认100%采样,其性能要比9i和10g中更优,因此一般情况下,建议使用DBMS_STATS.AUTO_SAMPLE_SIZE,由Oracle来自主选择采样比例。
4. 我之前说的,默认采样比例是100%,其实是需要有一些前提条件的,从1-3可以看出,9i确实默认是100%,但10g肯定不是了,11g一般情况下是100%,但不能保证所有情况均为100%。