OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase AI DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog ServiceOceanBase DataPilotOceanBase OAgent

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase AI DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog ServiceOceanBase DataPilotOceanBase OAgent
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase OAgent

V2.2.0
  • Product overview
    • What is OAgent?
    • Key features
    • System architecture
    • Use cases
  • Quick start
  • Deployment
  • Overview
  • Sessions and diagnosis
    • Manage sessions
    • Switch dialogue models
    • Use @ to mention the analysis target
    • View the tool invocation process
    • Upload an attachment
    • Data visualization
    • FAQ
    • Export a report
  • Tools
  • Skill Management
  • Channel management
  • Knowledge base
    • Built-in knowledge base
    • Custom knowledge base
  • Scheduled tasks
    • Overview of scheduled tasks
    • Create a scheduled task
  • View usage
  • Model configuration
    • Manage model services
    • Model scoring
  • Settings and security
    • Product management
    • Experimental features
  • Best practices
    • Perform a cluster health inspection
    • Query cluster and topology information
    • Query resource metrics and task status
    • Read-only queries
    • Alert query and troubleshooting guide
    • Root cause analysis of exceptions
    • ASH diagnostic report
    • Analyze slow SQL, TopSQL, and abnormal SQL
    • SQL pre-analysis and tuning recommendations
    • Interpret execution plans
    • Diagnostic information statistics
    • Parameter check and change governance
    • Database change ticket
  • Appendix
    • Feature list
    • Built-in Skills
  • Release notes
    • OAgent V2.2.0 Release note
    • OAgent V2.1.0 Release note
    • OAgent V2.0.0 Release note
    • OAgent V1.8.0 Release note

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase OAgent
  3. V2.2.0

Analyze slow SQL, TopSQL, and abnormal SQL

Last Updated:2026-11-20 07:25:11

When to use
Prerequisites
Procedure
Best practices
What to do next

This topic describes how to locate slow queries, identify the top resource-consuming SQL statements within a specified time period, and detect SQL statements with execution anomalies through dialogue.

When to use

  • Business personnel report that an API has become slower, and you need to determine whether it is caused by slow SQL on the database side.

  • The CPU or I/O utilization of the cluster has increased, and you need to locate the SQL statements that consume the most resources.

  • You know the SQL ID of a specific SQL statement and need to view its execution details and optimization suggestions.

Prerequisites

You have configured an OAS connection for the product to which the target cluster belongs. Data for slow SQL, TopSQL, and abnormal SQL all comes from OAS.

Procedure

  1. Type @ in the session to select the target cluster (a tenant is optional; specifying a tenant narrows the analysis scope).

  2. Describe your analysis requirements. You can use any of the following methods:

    • Specify a time range, for example:

      Identify the slowest SQL statements in the last hour.
      
    • Provide the SQL ID directly, for example:

      Analyze the SQL statement with SQL ID 8A2B...
      
    • Query for SQL statements with execution anomalies, for example:

      Identify SQL statements with execution anomalies in the last hour.
      
  3. Press Enter to send the request and wait for the Agent to complete the analysis.

    The Agent calls the diagnostic interface to obtain lists of slow SQL, TopSQL, and abnormal SQL statements, the SQL text, and information about the involved databases and tables.

  4. View the analysis results.

    The Agent outputs a list of problematic SQL statements, including performance metrics such as execution count, average time consumed, logical reads/physical reads, and number of rows returned, and provides optimization suggestions.

Best practices

  • When describing the time range, be as precise as possible to the window when the issue occurred (for example, "10:00 to 10:30 today"). A too-wide range will significantly increase query execution time.

  • Before adopting an index suggestion, evaluate the maintenance cost of the new index based on your business write volume, and execute it within the change window according to your enterprise's change process.

What to do next

  • To further confirm the execution plan risk of a specific SQL statement, you can ask the Agent to perform a pre-analysis. For more information, see SQL pre-analysis and tuning suggestions.

  • If you have obtained the execution plan and want to understand the meaning of each operator, see Execution plan interpretation.

  • To export the diagnostic conclusion as a report, see Export a report.

Previous topic

ASH diagnostic report
Last

Next topic

SQL pre-analysis and tuning recommendations
Next
on this page
When to use
Prerequisites
Procedure
Best practices
What to do next