Skip to main content

AI SQL Diagnosis and Optimization

AI SQL Diagnosis and Optimization analyzes the current SQL statement and returns diagnosis results, performance risks, and optimization suggestions. Use it to speed up query review before changing SQL or object design.

What It Does

  • Analyzes SQL structure, access paths, and potential risks.
  • Provides suggestions related to indexes, statement patterns, table design, execution behavior, and database-specific compatibility.
  • Returns recommendations only. It does not directly modify or execute SQL.

Before you begin

  • Open the SQL Console for the target data source in NineData.
  • The current account has at least read-only permission on the target data source.
  • Supported data sources include MySQL, Hive, DWS, Lindorm MySQL, Doris, TiDB, Vastbase, KingBaseES Oracle, TDSQL-C MySQL, TDSQL MySQL, PolarDB MySQL, PolarDB-X, PolarDB Oracle, SQL Server, PostgreSQL, Elasticsearch, OceanBase MySQL, OceanBase Oracle, Greenplum, StarRocks, MongoDB, DaMeng, GBase, Oracle, Sybase, AnalyticDB PostgreSQL, GreatSQL, Klustron, GoldenDB, MariaDB, KingBaseES, Db2, ClickHouse, GaussDB, SingleStore, SelectDB, and openGauss.

Procedure

  1. Open the SQL Console for the target data source. For more information, see SQL Console (RDBMS).
  2. Type, paste, or select the SQL you want to analyze.
  3. Place the cursor inside the target statement or select the entire statement.
  4. Click the SQL Optimize entry in the toolbar, or call the same feature from the right-click menu.
  5. Wait for the analysis to finish, then review the suggestions and adjust SQL or object design when required.

Typical Output Dimensions

DimensionDescription
Current execution assessmentHelps evaluate cost, execution duration, and overall risk
Structure and constraintsChecks whether primary keys, unique constraints, or design choices need improvement
Indexes and access pathsIdentifies full table scans, missing indexes, or weak index usage
SQL pattern improvementsHighlights issues such as SELECT *, unnecessary sorting, or inefficient filters
Long-term governance suggestionsGives broader advice for maintainable schema and object design

Result

NineData returns advisory optimization output. Confirm each suggestion with execution plans, business logic, data distribution, and change-management requirements before applying it in production.