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
- Open the SQL Console for the target data source. For more information, see SQL Console (RDBMS).
- Enter or paste the SQL statement to analyze.
- Place the cursor inside the statement or select the complete statement.
- Click the optimized SQL icon, or right-click and select SQL Optimize.
- Wait for the analysis to finish and review the results.
Result dimensions
| Dimension | Description |
|---|---|
| Current execution assessment | Reviews table size, query cost, execution time, temporary tables, and file sorting. |
| Structure and constraints | Identifies missing primary keys, unique constraints, or other structural risks and may provide DDL suggestions. |
| Indexes and access paths | Reviews current indexes, access methods such as full table scans, and the number of scanned rows. |
| SQL pattern and semantic optimization | Highlights patterns such as SELECT * and recommends explicit columns or other rewrites. |
| Table design and long-term optimization | Suggests improvements for primary keys, unique constraints, data types, defaults, partitions, or table splitting. |
| Execution plan interpretation | Explains scan types, scanned rows, sorting, temporary tables, and expected plan changes. |
| Optimization summary | Summarizes suggestions and recommends an implementation order. |
Review every suggestion against execution plans, business logic, data distribution, and change-management requirements before applying it.