Oracle Histograms – METHOD_OPT option in DBMS_STATS

When collecting statistics with DBMS_STATS in 9i, the default value of METHOD_OPT was ‘FOR ALL COLUMNS SIZE 1′. This basically says to Oracle please only collect basic column statistics (min, max, distinct values etc.), do not collect histograms on these columns.

For columns that are evenly distributed and for columns that are not referenced in SQL statements, this is perfectly adequate. If a column was unevenly distributed and detrimentally impacted the CBO’s costings of an execution plan, then one could generate histograms for those particular columns separately.

The new default value of METHOD_OPT with 10g is ‘FOR ALL COLUMNS SIZE AUTO’. This basically means that Oracle will automatically decide for us which columns need histograms and which columns don’t based on what it considers to be the distribution of values within a column and based on the “workload” associated with the table (basically are there any SQL statements running in the database referencing columns which might need histograms for those statements to be costed correctly).

This silly little demo, “Dangers of default METHOD_OPT behaviour in 10g“,

Oracle has got it wrong one way or the other in varying degrees in all three examples. It hasn’t created a histogram when it was needed and created histograms when they weren’t needed, impacting the Density column statistics as a result.

Understand 10g default method_opt being ‘for all columns size auto’
and the modification of using
method_opt => ‘for all columns size 1’ to avoid generation of (unnecessary) histograms.

The default ‘method_opt’ of Oracle 11g ( is AUTO.

SQL> select dbms_stats.get_param('method_opt') from dual;


Recommendation is still to generally use FOR ALL COLUMNS SIZE 1 and only collect histograms as and when required, even in 11g R2.

exec dbms_stats.gather_table_stats ('SCOTT','EMP', cascade=>TRUE,method_opt=>'FOR ALL COLUMNS SIZE 1');

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.