Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 








Oracle Concepts - Gathering Oracle CBO Statistics

Oracle Tips by Burleson Consulting

Gathering Oracle CBO Statistics

This examines collection of statistics for the cost-based optimizer (CBO).  A new DBA task in Oracle Database 10g is to generate statistics on data dictionary objects which are contained in the SYS schema. The stored procedures dbms_stats.gather_database_stats and dbms_stats.gather_schema_stats can be used to gather the SYS schema stats. Here is an example of using dbms_stats.gather_schema_stats to gather data dictionary statistics:

EXEC dbms_stats.gather_schema_stats(?SYS?);

It?s a good idea to gather data dictionary statistics on a regular basis, say once a week on a database with average activity.

Gathering Fixed Table CBO Statistics

Many of the Oracle data dictionary objects are what are called fixed tables because the DBA generally can?t modify them. (in fact, some of the data dictionary objects can be modified, but you should never ever do this).

The procedures dbms_stats.gather_database_stats and dbms_stats.gather_schema_stats offer the gather_fixed parameter. When set to TRUE the gather_fixed parameter will cause fixed table statistics to be gathered along with regular database statistics. Here is an example of the collection of data dictionary stats and also the collection of fixed table statistics:

EXEC dbms_stats.gather_schema_stats(?SYS?, gather_fixed=>TRUE);


Scheduling CBO statistics collection

Determining when to collect statistics is not as easy as it seems. If you create a table, and then generate statistics on it, are those statistics really good? If the table is going to be populated with lots of data at a later time, then the statistics created when the table was first created will probably be no good. A table with a million rows will often generate a very different plan than a table with just 10.

If tables are static, then you will probably need to analyze them only when they change. If tables are dynamic, then a reoccurring analyze operation is probably the best thing to do. Analyzing your dynamic tables once a day is far from unusual.

Sometimes you might actually have to create your own user defined statistics in order to get good performance from new tables. This is fairly rare, and is an advanced DBA topic, but we wanted you to know that it was possible to create your own statistics.

Automatic Collection of CBO Statistics

Oracle Database 10g actually automates the collection of database statistics out of the box. When an Oracle database is created, a job will be scheduled that will generate the database statistics for you. You will still need to collect system statistics however, as these are not collected by the automatic statistics gathering mechanism.

You can disable this automated statistics collection job using the dbms_scheduler.disable procedure as seen here:

EXEC dbms_scheduler.disable(?GATHER_STATS_JOB?);

You can re-enable the job using the dbms_scheduler.enable procedure as seen here:

EXEC dbms_scheduler.enable(?GATHER_STATS_JOB?);

This is an excerpt from the bestselling "Easy Oracle Jumpstart" by Robert Freeman and Steve Karam (Oracle ACE and Oracle Certified Master).  It?s only $19.95 when you buy it directly from the publisher here.

If you like Oracle tuning, you may enjoy the new book "Oracle Tuning: The Definitive Reference", over 900 pages of BC's favorite tuning tips & scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational