Why is this slow
why_is_this_slowDiagnose slow SQL queries by analyzing query plans, blocking, cache, and maintenance without executing the query. Get categorized suggestions for performance optimization.
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')
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 |
|---|---|---|---|
| sql | Yes | ||
| suggestions | Yes | ||
| explain_plan | Yes | ||
| plan_summary | Yes | ||
| active_queries | Yes | ||
| blocking_locks | Yes | ||
| cache_hit_ratio | Yes |