Optimize query
optimize_queryIdentify and fix SQL anti-patterns and performance issues by analyzing EXPLAIN plan costs and index scans, returning an optimized query.
Instructions
Analyze a SQL query for syntax anti-patterns and performance issues using EXPLAIN plan costs and index scans, returning an optimized version.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| findings | Yes | ||
| rationale | Yes | ||
| original_sql | Yes | ||
| optimized_sql | Yes | ||
| explain_summary | Yes |