OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.6.0

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.6.0
    iconOceanBase Database
    SQL - V 4.6.0
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    GATHER_INDEX_STATS

    Last Updated:2026-05-07 11:26:25  Updated
    Share
    What is on this page
    Syntax
    Parameters
    Exceptions
    Considerations
    Examples

    folded

    Share

    The GATHER_INDEX_STATS procedure is used to collect index statistics.

    Syntax

    DBMS_STATS.GATHER_INDEX_STATS (
      ownname            VARCHAR2,
      indname            VARCHAR2,
      partname           VARCHAR2 DEFAULT NULL,
      estimate_percent   NUMBER DEFAULT AUTO_SAMPLE_SIZE,
      stattab            VARCHAR2 DEFAULT NULL,
      statown            VARCHAR2 DEFAULT NULL,
      degree             NUMBER DEFAULT NULL,
      granularity        VARCHAR2 DEFAULT DEFAULT_GRANULARITY,
      no_invalidate      BOOLEAN DEFAULT FALSE,
      force              BOOLEAN DEFAULT FALSE,
      tabname            VARCHAR2 DEFAULT NULL
    );
    

    Parameters

    Parameter
    Description
    ownname The schema where the table is located.
    indname The name of the index.
    partname The name of the partition.
    estimate_percent The percentage of rows to estimate. Valid range: [0.000001,100].
    stattab The name of the table where the statistics are stored.
    statown The name of the user who owns the table where the statistics are stored.
    degree The degree of parallelism. The default value is NULL. When NULL is specified, the default value specified by the DEGREE clause of the CREATE TABLE or ALTER TABLE statement is used. If the size of the object cannot be guaranteed to support parallel execution, DBMS_STATS may execute the operation in serial mode.
    granularity The granularity of the index statistics to collect. This parameter is applicable only when the table is partitioned.
    • ALL: Collect statistics for all (subpartitions, partitions, and global) indexes.
    • APPROX_GLOBAL AND PARTITION: Similar to GLOBAL AND PARTITION, but in this case, global index statistics are aggregated at the partition level. This option aggregates all index statistics except the number of distinct values and the number of distinct keys. However, only partitions with index statistics are aggregated. If partname is NULL or if aggregation cannot be performed (for example, if statistics for one or more partitions are missing), global index statistics are collected.
    • AUTO: The granularity is determined based on the partition type. This is the default value.
    • DEFAULT: Collect statistics for the global and partition levels. This option is deprecated. We recommend that you use GLOBAL AND PARTITION instead.
    • GLOBAL: Collect global index statistics.
    • GLOBAL AND PARTITION: Collect statistics for the global and partition levels. Subpartition-level statistics are not collected for composite partitioned objects.
    • PARTITION: Collect statistics for the partition level.
    • SUBPARTITION: Collect statistics for the subpartition level.
    no_invalidate Specifies whether to invalidate the plan cache when collecting statistics. If set to TRUE, the plan cache is not invalidated when collecting statistics.
    force Specifies whether to forcibly collect statistics and ignore the lock status. The default value is FALSE. If set to TRUE, index statistics are collected even if the statistics are locked.
    tabname The name of the table.

    Exceptions

    Error code
    Description
    HY000
    • The index does not exist or the user does not have sufficient privileges.
    • The input value is invalid.

    Considerations

    To call this procedure, you must be the owner of the table. For objects owned by SYS, you must be the owner of the table or have the SYSDBA privilege.

    Examples

    Collect statistics for the idx index of the tbl1 table of the testUser01 user.

    obclient> CALL DBMS_STATS.GATHER_INDEX_STATS('testUser01', 'idx1', degree=>4, tabname=>'tbl1');
    Query OK, 0 rows affected
    

    Note

    In OceanBase Database in Oracle mode, you do not need to specify the tabname parameter because indexes are unique under the current user. However, in MySQL mode, you must explicitly specify the table name because indexes are not unique under the current user.

    Previous topic

    FLUSH_DATABASE_MONITORING_INFO
    Last

    Next topic

    GATHER_TABLE_STATS
    Next
    What is on this page
    Syntax
    Parameters
    Exceptions
    Considerations
    Examples