Ask the Expert

Using the ANALYZE command

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


This was first published in July 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: