optimize_query
Rewrites a slow read-only SQL query to run faster by testing model-proposed variants that return identical rows under the caller's roles, then returns the quickest with timings and every attempt.
Instructions
Make a slow read faster: the server's model proposes rewrites, each must return identical rows and pass run_query's checks, and the fastest one is returned with both timings and every attempt. If nothing is both identical and faster, the original comes back. Runs the query several times (bounded by a time budget). Only available when the server has a model configured; otherwise use explain_query and compare_queries with your own model.
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": {
"sql": "<sql>"
},
"name": "optimize_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One read-only SELECT (or WITH ... SELECT) written against the DDL select_schema returned. Writes, DDL and multiple statements are refused, as is any table or column this caller may not read. | |
| roles | No | The caller's roles or groups, e.g. ['finance', 'payroll']. Objects and columns restricted to a role are visible only when it is listed here. Omitted = no roles. | |
| principal | No | Who is asking, as an identity string such as 'okta:jdoe'. Pass it whenever you know the user: visibility is decided for this identity. Omitted = anonymous, which sees only unrestricted objects. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |