OceanBase logo

OceanBase

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

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

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

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.2.2

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    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.2.2
    iconOceanBase Database
    SQL - V 4.2.2
    SQL
    KV
    • 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

    Manage WR

    Last Updated:2026-04-15 08:27:14  Updated
    share
    What is on this page
    Create a snapshot
    Configure a snapshot strategy
    Configure the snapshot interval and retention period
    View snapshot configurations
    Delete snapshots
    References

    folded

    share

    OceanBase Database provides a database management system (DBMS) package for you to manage cluster snapshots related to Workload Repository (WR). Specifically, you can manually create snapshots, delete snapshots, and modify the time interval of the timer thread to adjust the sampling frequency for cluster snapshots.

    Notice

    This feature is supported only in the sys tenant, and is unavailable during upgrade.

    Create a snapshot

    WR automatically creates snapshots. To adjust the snapshot collection time, you can manually create a cluster snapshot. Then, the timer will collect data based on the new time interval. The syntax for creating a snapshot is as follows:

    DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT(
        flush_level  VARCHAR(64) DEFAULT 'TYPICAL'
        );
    

    In the syntax, the value of flush_level can be only TYPICAL, which indicates the periodic snapshot mode. This means WR collects most statistical data only in periodic snapshot mode. Here is an example:

    obclient [(none)]> CALL DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT(flush_level => 'TYPICAL');
    Query OK, 0 rows affected, 3 warnings (1.112 sec)
    

    Notice

    After you manually create a snapshot, the timer restarts counting down. For example, if you enable the periodic snapshot mode when the default time interval of the timer is 1 hour:

    • At 12:21, the timer triggers the creation of a snapshot.
    • At 13:21, the timer triggers the creation of the next snapshot.
    • At 13:45, you manually create a snapshot.
    • At 14:45, the timer triggers the creation of the next snapshot.
    After you manually create a snapshot, the timer triggers the creation of the next snapshot based on the set interval.

    Configure a snapshot strategy

    Configure the snapshot interval and retention period

    You can modify the snapshot interval and retention period to adjust the sampling frequency of cluster snapshots. The syntax is as follows:

    DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(
       retention          INT    DEFAULT  NULL,
       interval           INT    DEFAULT  NULL
       );
    

    The following table describes the fields.

    Field Description
    retention The retention period of snapshots, in minutes. Snapshots that exceed this period are automatically deleted. The value range is [1440 minutes (1 day), 52560000 minutes (100 years)].
    • The value 0 specifies to permanently retain the snapshots. In this case, the retention period is 57816000 minutes (110 years).
    • The value NULL specifies to use the original retention period.
    interval The time interval between snapshots, in minutes. The value range is [10 minutes, 525600 minutes (1 year)].
    • The value 0 specifies to disable automatic and manual snapshots and to use a large value defined by the system (110 years) as the retention period.
    • The value NULL specifies to use the current time interval.

    Example: Set the snapshot retention period to 2,265 minutes (about 1 day and 12 hours) and the interval between snapshots to 16 minutes.

    obclient [(none)]> CALL DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS('2265','16');
    Query OK, 0 rows affected (0.006 sec)
    

    View snapshot configurations

    • Query the oceanbase.CDB_WR_CONTROL view for WR related configurations in all tenants.

      obclient [oceanbase]> SELECT * FROM oceanbase.CDB_WR_CONTROL;
      

      The return result is as follows:

        +-----------+---------------+-------------+---------+
        | TENANT_ID | SNAP_INTERVAL | RETENTION   | TOPNSQL |
        +-----------+---------------+-------------+---------+
        |         1 | +0 00:16:00   | +1 13:45:00 |      30 |
        +-----------+---------------+-------------+---------+
        1 row in set (0.018 sec)
      

      The following table describes the fields.

      Field Description
      TENANT_ID
      • The ID of the tenant.
      • Other values: a user tenant or meta tenant.
      SNAP_INTERVAL The interval between snapshots, in the DD HH:mm:SS format.
      RETENTION The retention period of snapshots, in the DD HH:mm:SS format.
      TOPNSQL The top N SQL statement stored.

      For more information about the oceanbase.CDB_WR_CONTROL view, see oceanbase.CDB_WR_CONTROL.

    • Query the oceanbase.DBA_WR_CONTROL view in a user tenant for WR related configurations in the current tenant.

      obclient [oceanbase]> SELECT * FROM oceanbase.DBA_WR_CONTROL;
      

      The return result is as follows:

        +-----------+---------------+-------------+---------+
        | TENANT_ID | SNAP_INTERVAL | RETENTION   | TOPNSQL |
        +-----------+---------------+-------------+---------+
        |         1 | +0 00:16:00   | +1 13:45:00 |      30 |
        +-----------+---------------+-------------+---------+
        1 row in set (0.003 sec)
      

      The following table describes the fields.

      Field Description
      TENANT_ID
      • The ID of the tenant.
      • Other values: a user tenant or meta tenant.
      SNAP_INTERVAL The interval between snapshots, in the DD HH:mm:SS format.
      RETENTION The retention period of snapshots, in the DD HH:mm:SS format.
      TOPNSQL The top N SQL statement stored.

      For more information about the DBA_WR_CONTROL view, see oceanbase.DBA_WR_CONTROL and DBA_WR_CONTROL.

    • Query the oceanbase.CDB_WR_SNAPSHOT view for snapshots of all tenants.

      obclient [oceanbase]> SELECT * FROM oceanbase.CDB_WR_SNAPSHOT limit 1;
      

      The return result is as follows:

        +------------+-----------+---------+----------------+----------+----------------------------+----------------------------+-----------+----------------------------+
        | CLUSTER_ID | TENANT_ID | SNAP_ID | SVR_IP         | SVR_PORT | BEGIN_INTERVAL_TIME        | END_INTERVAL_TIME          | SNAP_FLAG | STARTUP_TIME               |
        +------------+-----------+---------+----------------+----------+----------------------------+----------------------------+-----------+----------------------------+
        |       4000 |         1 |     114 | xx.xx.xx.xx |     2882 | 2023-09-22 01:20:58.332785 | 2023-09-22 02:20:58.333136 |         0 | 2023-09-21 16:21:41.723234 |
        +------------+-----------+---------+----------------+----------+----------------------------+----------------------------+-----------+----------------------------+
        1 row in set (0.004 sec)
      

      The following table describes the fields.

      Field Description
      CLUSTER_ID The ID of the cluster.
      TENANT_ID The ID of the tenant.
      SNAP_ID The ID of the snapshot.
      SVR_IP The IP address of the server.
      SVR_PORT The port of the server.
      BEGIN_INTERVAL_TIME The snapshot start time, which is a timestamp accurate to milliseconds.
      END_INTERVAL_TIME The snapshot end time, which is a timestamp accurate to milliseconds.
      SNAP_FLAG The reason for triggering the snapshot
      STARTUP_TIME The time when the process was started, which is a timestamp accurate to milliseconds.

      For more information about the oceanbase.CDB_WR_SNAPSHOT view, see oceanbase.CDB_WR_SNAPSHOT.

    • Query the oceanbase.DBA_WR_SNAPSHOT view for snapshots of the current tenant.

      obclient [oceanbase]> SELECT * FROM oceanbase.DBA_WR_SNAPSHOT limit 1;
      

      The return result is as follows:

        +------------+-----------+---------+----------------+----------+----------------------------+----------------------------+-----------+----------------------------+
        | CLUSTER_ID | TENANT_ID | SNAP_ID | SVR_IP         | SVR_PORT | BEGIN_INTERVAL_TIME        | END_INTERVAL_TIME          | SNAP_FLAG | STARTUP_TIME               |
        +------------+-----------+---------+----------------+----------+----------------------------+----------------------------+-----------+----------------------------+
        |       4000 |         1 |     114 | xx.xx.xx.xx |     2882 | 2023-09-22 01:20:58.332785 | 2023-09-22 02:20:58.333136 |         0 | 2023-09-21 16:21:41.723234 |
        +------------+-----------+---------+----------------+----------+----------------------------+----------------------------+-----------+----------------------------+
        1 row in set (0.004 sec)
      

      The following table describes the fields.

      Field Description
      CLUSTER_ID The ID of the cluster.
      TENANT_ID The ID of the tenant.
      SNAP_ID The ID of the snapshot.
      SVR_IP The IP address of the server.
      SVR_PORT The port of the server.
      BEGIN_INTERVAL_TIME The snapshot start time, which is a timestamp accurate to milliseconds.
      END_INTERVAL_TIME The snapshot end time, which is a timestamp accurate to milliseconds.
      SNAP_FLAG The reason for triggering the snapshot
      STARTUP_TIME The time when the process was started, which is a timestamp accurate to milliseconds.

      For more information about the DBA_WR_SNAPSHOT view, see oceanbase.DBA_WR_SNAPSHOT and DBA_WR_SNAPSHOT.

    Delete snapshots

    Notice

    1. Before you delete snapshots, make sure that the snapshot IDs are valid in the system.
    2. After you delete the snapshots, the snapshot data within the specified range will be permanently deleted. Proceed with caution.

    You can specify the start ID and end ID of snapshots to delete the snapshot data within the specified ID range. The syntax is as follows:

    DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE(
        low_snap_id    INT,
        high_snap_id   INT
        );
    

    The following table describes the fields.

    Field Description
    low_snap_id The start ID of snapshots to be deleted.
    high_snap_id The end ID of snapshots to be deleted.

    The snapshot deletion procedure is as follows:

    1. Query all snapshot IDs in the tenant.

      obclient [oceanbase]> select count(1),min(snap_id), max(snap_id) from oceanbase.DBA_WR_SNAPSHOT;
      

      The return result is as follows:

      +-----------+--------------+--------------+
      | count(1) | min(snap_id) | max(snap_id) |
      +-----------+--------------+--------------+
      |         1 |            2 |            2 |
      +-----------+--------------+--------------+
      1 row in set (0.039 sec)
      
    2. Delete the snapshot data within the specified ID range.

      obclient [oceanbase]> CALL DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE('2','2');
      Query OK, 0 rows affected (1.018 sec)
      
    3. Query whether the snapshots are successfully deleted.

      obclient [oceanbase]> select count(1),min(snap_id), max(snap_id) from oceanbase.DBA_WR_SNAPSHOT;
      

    References

    • Overview
    • Monitor historical session performance
    • Clean up WR data

    Previous topic

    Overview
    Last

    Next topic

    Monitor historical session performance
    Next
    What is on this page
    Create a snapshot
    Configure a snapshot strategy
    Configure the snapshot interval and retention period
    View snapshot configurations
    Delete snapshots
    References