Why is this slow
why_is_this_slowDiagnose slow SQL queries by running EXPLAIN without executing them, inspecting plans, contention, and cache stats, then returning categorized tuning suggestions.
Instructions
Diagnose why a SQL query might be slow, in one call. Runs EXPLAIN (FORMAT JSON) — does NOT execute the query — walks the plan tree, snapshots concurrent active queries + blocking lock pairs, reads the cluster-wide cache hit ratio, and produces categorised suggestions (plan / contention / cache / maintenance). Read-only; safe to run on a statement the agent doesn't want to materialise yet.
Example: why_is_this_slow(sql='SELECT * FROM orders WHERE customer_id = 42')
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": "why_is_this_slow"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| database | No | Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| suggestions | Yes | ||
| explain_plan | Yes | ||
| plan_summary | Yes | ||
| active_queries | Yes | ||
| blocking_locks | Yes | ||
| cache_hit_ratio | Yes |