explain_query
Get the execution plan of any SQL query without running it, using EXPLAIN. Optionally include ANALYZE to execute and measure actual runtime, with configurable verbosity to control detail.
Instructions
Muestra el plan de ejecucion de una consulta (EXPLAIN). Sin ANALYZE por defecto.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | Consulta SQL a analizar | |
| params | No | Parametros | |
| analyze | No | Ejecutar ANALYZE (ojo: ejecuta la query realmente) | |
| verbosity | No | Controls result detail to save context tokens. Default: 'normal'. - 'minimal': Only rowCount, executionTimeMs, affectedRows, and preview of first row. USE FOR: INSERT/UPDATE/DELETE where you only need to confirm success, COUNT queries, health-style SQL ("SELECT 1"), polling a job status. SAVES: ~90-95% tokens. - 'normal' (DEFAULT): Full rows but each CELL truncated to max_cell_bytes. Preserves table structure. Cells flagged with trailing '…(+NB)' marker when truncated. USE FOR: most SELECT debugging — browsing tables with TEXT/JSONB columns, exploring data. SAVES: ~60-80% tokens on tables with large columns (content, html, json payloads). - 'full': Entire result untouched. SAME SHAPE AS pre-compression releases. USE FOR: when you explicitly need the complete value of every cell. If a cell is truncated you can call inspect_last_query({ call_id }) to recover the full result WITHOUT re-executing the SQL (preserves DB load and any side-effects). | |
| only_columns | No | Return only these columns from the result (client-side projection after fetch). Cheaper than full when the SQL already returned extra columns you don't need. Example: ["id", "title", "slug"] drops all other columns from the response. | |
| max_cell_bytes | No | Max bytes per cell for verbosity='normal' (default: 500). Cells longer than this are truncated with '…(+NB)' suffix. Ignored for minimal/full. | |
| max_rows_in_response | No | Cap rows returned to the agent (does NOT change the SQL LIMIT). Useful to peek at a big result. Default: no cap beyond SQL LIMIT. |