SET_INDEX_STATS

2023-07-28 02:55:43  Updated

The SET_INDEX_STATS procedure sets index-related information.

Syntax

DBMS_STATS.SET_INDEX_STATS (
  ownname            VARCHAR2,
  indname            VARCHAR2,
  partname           VARCHAR2  DEFAULT NULL,
  numrows            NUMBER    DEFAULT NULL,
  force              BOOLEAN   DEFAULT FALSE,
  avgrlen            NUMBER    DEFAULT NULL,
  nummacroblks       NUMBER    DEFAULT NULL,
  nummicroblks       NUMBER    DEFAULT NULL,
  tabname            VARCHAR2  DEFAULT NULL);

Parameters

Parameter Description
ownname The schema to which the table belongs.
indname The name of the index.
partname The name of the partition.
numrows The number of rows in the index or partition.
force Specifies whether to forcibly set index information and ignore the lock status. Default value: FALSE. If you set the value to TRUE, index statistics will be set even if statistics are locked.
avgrlen The average row length of the index table, in bytes.
nummacroblks The number of macro blocks of the index table.
nummicroblks The number of micro blocks of the index table.
tabname The name of the table.

Exceptions

Error code Description
ORA-20000 The object does not exist, or you do not have the required privileges.
ORA-20001 The input value is invalid.
ORA-20005 Statistics on the object are locked.

Considerations

  • To call this procedure, you must be the owner of the table. If the object is owned by the sys tenant, you must be the owner of the table or have the SYSDBA privilege.

  • The optimizer estimates the number of cached blocks accessed by an index or a statistics table based on the cached data. The total costs of the operation consist of the I/O cost of reading uncached blocks from the disk, CPU cost of fetching cached blocks from the buffer cache, and CPU cost of processing data.

Examples

Set the information of the idx1 index of the testUser01 user.

obclient> CALL DBMS_STATS.SET_INDEX_STATS('testUser01', 'idx1', numrows=>10, avgrlen=>10, tabname=>'tbl1');
Query OK, 0 rows affected

Note

In Oracle mode, you do not need to specify the tabname parameter because the index is unique under the current user. In MySQL mode, you must specify the table name because indexes are not unique under the current user.

Contact Us