Explain Query
kb_explainAnalyze SQL query performance by retrieving execution plans. Identify full table scans, join strategies, and optimize queries with optional real timing data.
Instructions
Get the execution plan for a SQL query using EXPLAIN.
Use this to analyze query performance, identify full table scans, and optimize queries.
Args:
sql (string): The SQL query to explain
analyze (boolean, default false): If true, actually executes the query (EXPLAIN ANALYZE) for real timing data
format ('text' | 'json' | 'yaml'): Output format (default: 'text')
Returns: Query execution plan showing scan types, costs, and join strategies.
Examples:
sql: "SELECT * FROM users WHERE email = 'test@example.com'"
sql: "SELECT u., o. FROM users u JOIN orders o ON u.id = o.user_id", analyze: true
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL query to explain | |
| format | No | Output format for the execution plan | text |
| analyze | No | Run EXPLAIN ANALYZE (actually executes the query) for real timing data |