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 parameter is set to NULL, the current login 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 statistics information and ignore the lock status. The default value is FALSE. If you set the value to TRUE, index statistics will be specified 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 |
|---|---|
| OBE-20000 | The object does not exist, or you do not have the required privileges. |
| OBE-20001 | The input value is invalid. |
| OBE-20005 | Statistics on the object are locked. |
Considerations
To call this procedure, you must be the owner of the table. To call this procedure on a table object owned by the
SYSuser, you must be the table owner or have theSYSDBAprivilege.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
TRUEorFALSEmust be executed in theBEGIN ... ENDblock.
Examples
Set the information about the idx1 index for 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-compatible mode, you do not need to specify the tabname parameter because the index is unique under the current user. In MySQL mode, you must explicitly specify the table name because indexes are not unique under the current user.