
Update Statistics: Internal Rules with SAPDBA
This section describes the rules used by the cost-based optimizer (CBO) to update statistics for the Oracle database. The rules apply to both the older two-phase approach and the newer
integrated approach to update statistics with SAPDBA.
We strongly recommend you to use the
Phase I: sapdba -checkopt
Phase I is based on the
analyze index command, which you can use to quickly display the current number of table records.Number of old table records |
Analysis method |
Sample option |
Records < 6,000 |
C |
|
6,000 < Records < 60,000 |
E |
P30 |
60,000 < Records < 600,000 |
E |
P10 |
600,000 < Records < 6,000,000 |
E |
P3 |
Records > 6,000,000 |
E |
P1 |
Analysis method C means compute the statistics exactly. Analysis method E means estimate the statistics using the sample option specified.
For example, "E P30" means that SAPDBA takes an estimated sample using 30% of rows.

If the customer flag is set, SAPDBA does not change the settings in the DBSTATC control table.
SAPDBA enters tables in the DBSTATC control table if either of the following is true:
SAPDBA enters the appropriate analysis methods and options in the DBSTATC control table according to the rules from the second step. SAPDBA uses the up-to-date number of table records from the third step when doing this.
SAPDBA deletes tables from the DBSTATC control table if either of the following is true:
Phase II: sapdba -analyze
SAPDBA uses the analysis method and option specified in the
DBSTATC control table if they create more precise statistics than those specified in the command option, or if the customer flag is set. If there is no entry in the control table for a table, then the analysis method and option from the second step in phase I are used.SAPDBA create statistics for all tables that require them:
For each
checkopt and analyze run, SAPDBA implicitly deletes the statistics ofSAPDBA explicitly deletes statistics for each
delete run.These statistics are also used by applications that need space information (such as the R/3 Application Monitor). When statistics are created, all tables with the
ACTIV flag set to R are analyzed; the statistics are then deleted. The statistics results are stored in the tables DBSTATTORA or DBSTATIORA .