Skip to main content

AI SQL Optimization

AI SQL Optimization analyzes the current SQL statement and provides optimization suggestions, helping you identify performance risks and possible improvements more quickly.

What It Does

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

Prerequisites

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

Steps

  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 as needed.

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

Tips

  • Treat the suggestions as advisory output and confirm them with execution plans and business logic before applying them in production.
  • If the statement has already failed, combine this feature with AI SQL Diagnosis.