How do you use the 'analyze' command to populate the statistic-related columns for a particular
table?
Requires Free Membership to View
The analyze command within the Oracle database collects statistics about an object. The information includes the distribution of data, the number of rows in the table and otehr important statistics. This information is collected and supplied to the optimizer to allow for the best possible execution path of a SQL statement.
If you are using the cost-based optimizer you must analyze your database objects. As well when you are analyzing your objects your should tell the database the size of the sample it should use if you wish to have the database estimate statistics (this is a faster method). If you wish for an exact computation of statistics you would use the "compute" argument.
To estimate statistics:
ANALYZE TABLE tablename ESTIMATE STATISTICS SAMPLE 30 PERCENT;
To compute statistics:
ANALYZE TABLE tablename COMPUTE STATISTICS;
You should also remember that statistics get old and dated, you should regularly schedule to re-analyze your tables and indexes.
For More Information
- Dozens more answers to tough data warehousing questions from Ian Abramson are available here.
- The Best Data Warehousing and Business Intelligence Web Links: tips, tutorials, scripts, and more.
- Have an DW tip to offer your fellow administrators and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical data warehousing questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
This was first published in July 2002

Join the conversationComment
Share
Comments
Results
Contribute to the conversation