get_query_plan
Analyze SQL SELECT query performance by generating estimated or actual XML execution plans. Identify optimization opportunities and understand query execution behavior.
Instructions
Get the estimated or actual XML execution plan for a SELECT query. Estimated plans show the optimizer's plan without executing. Actual plans execute the query and include runtime statistics. Uses the same query validation as read_data (SELECT only).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serverName | Yes | Name of the SQL Server to query (use list_servers to see available names) | |
| query | Yes | SQL SELECT query to get the execution plan for. Only SELECT and WITH (CTE) queries are permitted. | |
| databaseName | Yes | Name of the database to query (use list_databases to see available databases) | |
| outputPath | Yes | File path for output (e.g. '/tmp/plan.sqlplan') | |
| planType | No | Plan type: 'estimated' (default, does not execute) or 'actual' (executes the query) | estimated |