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

SQL pre-analysis and tuning recommendations

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

When to use
Prerequisites
Procedure
Considerations
What to do next

SQL pre-analysis is used to assess the risk of an SQL execution plan and can also provide tuning suggestions for existing SQL statements.

When to use

  • Assess whether the execution plan of a new SQL statement poses risks.

  • Improve the execution efficiency of an existing SQL statement by obtaining actionable index or rewrite suggestions.

  • Determine whether an SQL statement will trigger a full table scan.

Prerequisites

  • You have configured an OAS connection for the product of the target cluster.

  • You know the name of the database containing the SQL statement to be analyzed.

Procedure

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

  2. Provide the SQL text to be analyzed and its corresponding database, for example:

    Analyze the execution plan of the following SQL statement in the test database to check for risks:
    SELECT * FROM t_order WHERE create_time > '2026-01-01';
    
  3. Press Enter to send the request and wait for the Agent to complete the analysis.

    The Agent performs an EXPLAIN pre-analysis on the SQL statement to obtain the execution plan and the structure and statistics of related tables.

  4. View the analysis results.

    The output from the Agent typically includes the following sections:

    • Execution Plan: The operator tree and access path of the SQL statement.

    • Risk Points: For example, full table scan, missing indexes, or non-pushdown filter conditions.

    • Tuning Suggestions: Directly actionable optimization steps, such as recommended new index definitions.

Note

Pre-analysis only executes an EXPLAIN and does not actually run the SQL statement. However, the tuning suggestions, such as index recommendations, provided by the Agent are change operations. You must evaluate them and follow your enterprise's change process to implement them.

Considerations

  • When providing SQL text, please include the name of the database to which it belongs. Otherwise, the Agent cannot locate the table schema and statistics.

  • If the SQL contains bind variables, it is recommended to replace them with representative actual values to obtain a more accurate cost estimate.

  • Before adopting index or rewrite suggestions, evaluate the maintenance cost based on the business write volume, and execute the changes within the change window according to your enterprise's change process.

What to do next

  • To understand the meaning of each operator in an execution plan, see Interpretation of execution plans.

  • If the estimated number of rows differs significantly from the actual number of rows, it usually indicates that the statistics are outdated. You can proceed with statistics diagnostics. For more information, see Statistics diagnostics.

  • To export the analysis results to a report, see Export a report.

Previous topic

Analyze slow SQL, TopSQL, and abnormal SQL
Last

Next topic

Interpret execution plans
Next
on this page
When to use
Prerequisites
Procedure
Considerations
What to do next