Get Query Execution Plan
get_query_planRetrieve estimated or actual XML execution plans for SELECT queries to inspect optimizer behavior and runtime statistics for performance tuning.
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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL SELECT query to get the execution plan for. Only SELECT and WITH (CTE) queries are permitted. | |
| planType | No | Plan type: 'estimated' (default, does not execute) or 'actual' (executes the query) | estimated |
| outputPath | Yes | File path for output (e.g. '/tmp/plan.sqlplan') | |
| serverName | Yes | Name of the SQL Server to query (use list_servers to see available names) | |
| databaseName | Yes | Name of the database to query (use list_databases to see available databases) |