The DBMS_STATS package is used to view and modify the statistics collected by the optimizer for database objects.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Considerations
The DBMS_STATS system package in the current version of OceanBase Database supports the following common operations:
Collect optimizer statistics.
Set column, table, and index information.
Delete statistics.
Lock and unlock statistics.
Overview of DBMS_STATS subprograms
The following table lists the DBMS_STATS subprograms supported in the current OceanBase Database version and their brief descriptions.
| Procedure | Purpose |
|---|---|
| ALTER_STATS_HISTORY_RETENTION | Modifies the retention period for historical statistics. The default retention period is 31 days. |
| CREATE_STAT_TABLE | Creates a table for storing statistics in the specified user. |
| DELETE_COLUMN_STATS | Deletes column-level statistics. |
| DELETE_INDEX_STATS | Deletes statistics related to indexes. |
| DELETE_TABLE_STATS | Deletes table-level statistics. |
| DELETE_SCHEMA_STATS | Deletes statistics for all tables in the specified user. |
| DELETE_SCHEMA_PREFS | Deletes statistics preferences (Prefs) for all tables in the specified user. |
| DELETE_SYSTEM_STATS | Deletes system statistics |
| DELETE_TABLE_PREFS | Deletes statistics preferences (Prefs) for tables owned by the specified user. |
| DROP_STAT_TABLE | Drops the user information statistics table. |
| EXPORT_COLUMN_STATS | Exports column-level statistics. |
| EXPORT_INDEX_STATS | Retrieves statistics for the specified index and stores them in the statistics table. |
| EXPORT_TABLE_STATS | Exports table-level statistics. |
| EXPORT_SCHEMA_STATS | Exports statistics for all tables in the user. |
| FLUSH_DATABASE_MONITORING_INFO | Refreshes all table memory monitoring information to the dictionary. |
| GATHER_INDEX_STATS | Collects index statistics. |
| GATHER_TABLE_STATS | Collects statistics for tables and columns. |
| GATHER_SCHEMA_STATS | Collects statistics for all objects in the user. |
| GATHER_SYSTEM_STATS | Collects system statistics |
| GET_STATS_HISTORY_AVAILABILITY | Retrieves the earliest available time for historical statistics. Statistics cannot be restored for times earlier than this. |
| GET_STATS_HISTORY_RETENTION | Retrieves the retention period for historical statistics. |
| GET_PARAM | Retrieves the default values of parameters for procedures in the DBMS_STATS package. |
| GET_PREFS | Retrieves the default values of the specified preferences (Prefs). |
| IMPORT_INDEX_STATS | Retrieves statistics for the specified index from the user information statistics table and stores them in the dictionary. |
| IMPORT_COLUMN_STATS | Imports column-level statistics. |
| IMPORT_TABLE_STATS | Imports table-level statistics. |
| IMPORT_SCHEMA_STATS | Imports statistics for all tables under the current user. |
| LOCK_PARTITION_STATS | Locks partition statistics. |
| LOCK_SCHEMA_STATS | Locks statistics for all tables under the current user. |
| LOCK_TABLE_STATS | Locks table statistics. |
| RESTORE_TABLE_STATS | Restores table-level historical statistics at a specified time. |
| RESTORE_SCHEMA_STATS | Restores user-level historical statistics at a specified time. |
| RESET_GLOBAL_PREF_DEFAULTS | Resets global preferences to their default values. |
| RESET_PARAM_DEFAULTS | Resets all parameter defaults to the recommended values of the database. |
| PURGE_STATS | Deletes historical statistics before a specified time. |
| SET_COLUMN_STATS | Sets column-level basic statistics. |
| SET_INDEX_STATS | Sets index-related information. |
| SET_TABLE_STATS | Sets table-level basic statistics. |
| SET_GLOBAL_PREFS | Sets global statistics preferences. |
| SET_PARAM | Sets default values for parameters of procedures in the DBMS_STATS package. |
| SET_SCHEMA_PREFS | Sets statistics preferences for a specified user. |
| SET_SYSTEM_STATS | Sets system statistics |
| SET_TABLE_PREFS | Sets statistics preferences for tables owned by a specified user. |
| UNLOCK_PARTITION_STATS | Unlocks partition statistics. |
| UNLOCK_SCHEMA_STATS | Unlocks statistics for all tables under the current user. |
| UNLOCK_TABLE_STATS | Unlocks table statistics. |
| COPY_TABLE_STATS | Copies statistics from a source partition (or subpartition) to a target partition (or subpartition). |
| CANCEL_GATHER_STATS | Cancels a statistics collection command. |
