Oracle9i Supplied PL/SQL Packages and Types Reference Release 1 (9.0.1) Part Number A89852-02 |
|
DBMS_STATS
provides a mechanism for you to view and modify optimizer statistics gathered for database objects. The statistics can reside in the dictionary or in a table created in the user's schema for this purpose. Only statistics stored in the dictionary have an impact on the cost-based optimizer. You can also use DBMS_STATS to gather statistics in parallel.
This chapter contains the following topics:
The DBMS_STATS
subprograms perform the following general functions:
Most of the DBMS_STATS
procedures include the three parameters statown
, stattab
, and statid
. These parameters allow you to store statistics in your own tables (outside of the dictionary), which does not affect the optimizer. Therefore, you can maintain and experiment with sets of statistics.
The stattab
parameter specifies the name of a table in which to hold statistics, and it is assumed that it resides in the same schema as the object for which statistics are collected (unless the statown
parameter is specified). Users may create multiple tables with different stattab
identifiers to hold separate sets of statistics.
Additionally, users can maintain different sets of statistics within a single stattab
by using the statid
parameter, which can help avoid cluttering the user's schema.
For all of the SET
or GET
procedures, if stattab
is not provided (i.e., NULL
), then the operation works directly on the dictionary statistics; therefore, users do not need to create these statistics tables if they only plan to modify the dictionary directly. However, if stattab
is not NULL
, then the SET
or GET
operation works on the specified user statistics table, and not the dictionary.
Most of the procedures in this package commit the current transaction, perform the operation, and then commit again. These include:
Types for minimum/maximum values and histogram endpoints:
TYPE numarray IS VARRAY(256) OF NUMBER; TYPE datearray IS VARRAY(256) OF DATE; TYPE chararray IS VARRAY(256) OF VARCHAR2(4000); TYPE rawarray IS VARRAY(256) OF RAW(2000); type StatRec is record ( epc NUMBER, minval RAW(2000), maxval RAW(2000), bkvals NUMARRAY, novals NUMARRAY);
Types for listing stale tables:
type ObjectElem is record ( ownname VARCHAR2(30), -- owner objtype VARCHAR2(6), -- 'TABLE' or 'INDEX' objname VARCHAR2(30), -- table/index partname VARCHAR2(30), -- partition subpartname VARCHAR2(30), -- subpartition confidence NUMBER); -- not used type ObjectTab is TABLE of ObjectElem;
The constant used to indicate that auto-sample size algorithms should be used is:
AUTO_SAMPLE_SIZE CONSTANT NUMBER;
The constant used to determine the system default degree of parallelism, based on the initialization parameters, is:
DEFAULT_DEGREE CONSTANT NUMBER;
The following procedures enable the storage and retrieval of individual column-, index-, and table-related statistics:
PREPARE_COLUMN_VALUES SET_COLUMN_STATS SET_INDEX_STATS SET_SYSTEM_STATS SET_TABLE_STATS CONVERT_RAW_VALUE GET_COLUMN_STATS GET_INDEX_STATS GET_SYSTEM_STATS GET_TABLE_STATS DELETE_COLUMN_STATS DELETE_INDEX_STATS DELETE_SYSTEM_STATS DELETE_TABLE_STATS DELETE_SCHEMA_STATS DELETE_DATABASE_STATS
The following procedures enable the gathering of certain classes of optimizer statistics, with possible performance improvements over the ANALYZE
command:
GATHER_INDEX_STATS GATHER_TABLE_STATS GATHER_SCHEMA_STATS GATHER_DATABASE_STATS GATHER_SYSTEM_STATS
The statown
, stattab
, and statid
parameters instruct the package to backup current statistics in the specified table before gathering new statistics.
Oracle also provides the following procedure for generating some statistics for derived objects when we have sufficient statistics on related objects:
GENERATE_STATS
The following procedures enable the transference of statistics from the dictionary to a user stat table (export_
*) and from a user stat table to the dictionary (import_
*):
CREATE_STAT_TABLE DROP_STAT_TABLE EXPORT_COLUMN_STATS EXPORT_INDEX_STATS EXPORT_SYSTEM_STATS EXPORT_TABLE_STATS EXPORT_SCHEMA_STATS EXPORT_DATABASE_STATS IMPORT_COLUMN_STATS IMPORT_INDEX_STATS IMPORT_SYSTEM_STATS IMPORT_TABLE_STATS IMPORT_SCHEMA_STATS IMPORT_DATABASE_STATS
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|