query_optimizer
Diagnose slow SQL queries by generating EXPLAIN plans, table statistics, and index recommendations to improve performance.
Instructions
Optimize slow queries - EXPLAIN plan, table stats, index recommendations.
LEVEL: Query (single query optimization)
USE FOR: slow query diagnosis, CREATE INDEX suggestions, execution plans. DO NOT USE FOR: running queries (execute_query), syntax validation (analyze_query).
Examples: query_optimizer(query='SELECT * FROM orders WHERE customer_id=123', schema='shipment') query_optimizer(query='SELECT * FROM users', schema='public', run_explain=True)
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>"
},
"name": "query_optimizer"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL query to optimize | |
| run_explain | No | Run EXPLAIN ANALYZE (executes in rollback) | |
| timeout_ms | No | Timeout in ms (5 min default) | |
| schema | No | Schema for table stats lookup. REQUIRED. Use get_schema() to list available schemas. | |
| url | No | Database URL |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |