Skip to main content

AI SQL Optimization

The NineData SQL Console includes AI SQL Optimization. It analyzes a SQL statement and returns optimization suggestions without modifying or executing the statement.

Overview​

The feature evaluates SQL syntax, database-specific behavior, access paths, common performance risks, and table design. It returns advisory results only, so production data is not changed by the analysis.

Before you begin​

  • Open the SQL Console for the target data source.
  • Your 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.

Procedure​

  1. Open the SQL Console for the target data source. For more information, see SQL Console (RDBMS).
  2. Enter or paste the SQL statement to analyze.
  3. Place the cursor inside the statement or select the complete statement.
  4. Click the optimized SQL icon, or right-click and select SQL Optimize.
  5. Wait for the analysis to finish and review the results.

Result dimensions​

DimensionDescription
Current execution assessmentReviews table size, query cost, execution time, temporary tables, and file sorting.
Structure and constraintsIdentifies missing primary keys, unique constraints, or other structural risks and may provide DDL suggestions.
Indexes and access pathsReviews current indexes, access methods such as full table scans, and the number of scanned rows.
SQL pattern and semantic optimizationHighlights patterns such as SELECT * and recommends explicit columns or other rewrites.
Table design and long-term optimizationSuggests improvements for primary keys, unique constraints, data types, defaults, partitions, or table splitting.
Execution plan interpretationExplains scan types, scanned rows, sorting, temporary tables, and expected plan changes.
Optimization summarySummarizes suggestions and recommends an implementation order.

Review every suggestion against execution plans, business logic, data distribution, and change-management requirements before applying it.