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
- Open the SQL Console for the target data source. For more information, see SQL Console (RDBMS).
- Type, paste, or select the SQL you want to analyze.
- Place the cursor inside the target statement or select the entire statement.
- Click the SQL Optimize entry in the toolbar, or call the same feature from the right-click menu.
- Wait for the analysis to finish, then review the suggestions and adjust SQL or object design as needed.
Typical Output Dimensions
| Dimension | Description |
|---|---|
| Current execution assessment | Helps evaluate cost, execution duration, and overall risk |
| Structure and constraints | Checks whether primary keys, unique constraints, or design choices need improvement |
| Indexes and access paths | Identifies full table scans, missing indexes, or weak index usage |
| SQL pattern improvements | Highlights issues such as SELECT *, unnecessary sorting, or inefficient filters |
| Long-term governance suggestions | Gives 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.