SET_INDEX_STATS

2025-11-19 10:08:13  Updated

The SET_INDEX_STATS procedure sets index-related statistics information.

Applicability

This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.

Syntax

DBMS_STATS.SET_INDEX_STATS (
  ownname            VARCHAR2,
  indname            VARCHAR2,
  partname           VARCHAR2  DEFAULT NULL,
  numrows            NUMBER    DEFAULT NULL,
  no_invalidate      BOOLEAN   DEFAULT FALSE,
  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 username. If the username is set to NULL, the current logon username is used by default.
indname The name of the index.
partname The name of the partition.
numrows The number of rows in the index or partition.
no_invalidate Specifies whether to refresh the plan cache when statistics are collected. If you set the value to TRUE, the plan cache will not be refreshed during statistics collection.
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 in 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.

  • Procedures with parameters whose values are TRUE or FALSE must be executed in the BEGIN ... END block.

Examples

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

obclient> CALL DBMS_STATS.SET_INDEX_STATS('testUser01', 'idx1', numrows=>10, avgrlen=>10, '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