Execution plan summary
get_query_plan_summarySummarizes a Query Store or cached SQL Server execution plan, replacing bulky XML with per-statement cost, rows, warnings, missing indexes, and operator tree details.
Instructions
Summarizes one execution plan instead of returning its XML, which can run to hundreds of thousands of characters: a Query Store plan by plan_id, or a plan in the plan cache by plan_handle, whole or the one statement its offsets pick out. Per statement (an IF or WHILE condition and each cursor operation count as one): estimated rows and cost, cardinality estimator version, whether the plan is parallel and why not when it is serial, memory grant, the parameter values the plan was compiled for, the statistics the optimizer used with their last update and modifications, the warnings, each with the operator it is on (implicit conversions, missing statistics or join predicates), missing-index suggestions, and the operators as a compact tree with object, index, seek, scan or lookup, predicates and join keys, estimated rows and share of the cost. Query Store and cached plans are estimated plans, so nothing measured at run time, such as spills, is in them. Use it with a plan_id from get_query_store_history or list_query_store_regressions, or a plan_handle from find_cached_queries or get_active_requests, and compare two plans of a query by summarizing each; for the statistics themselves use get_table_statistics. A plan_handle needs VIEW SERVER STATE (2022+: VIEW SERVER PERFORMANCE STATE).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database": "<database>"
},
"name": "get_query_plan_summary"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| plan_id | No | Query Store plan id, from get_query_store_history or list_query_store_regressions. 0 (default) when plan_handle is given instead. | |
| database | Yes | Name of the database as registered in the configuration. | |
| statement | No | Number of one statement to return alone, its statement_number. 0 (default) returns every statement, or the 20 costliest, with statement_index listing them all, when there are more. | |
| plan_handle | No | A plan in the plan cache, as find_cached_queries or get_active_requests write its plan_handle: 0x and hexadecimal digits. Empty when plan_id is given instead. A plan the cache has dropped since is reported as gone; those tools give the handle of the plan in use now. | |
| max_operators | No | How many of the costliest operators to keep per statement (default 40, at most 200). Every operator above them comes too, so that the tree reads from the root, and operators_shown can exceed this. | |
| statement_end_offset | No | With plan_handle, where the statement ends, as those tools return it with statement_start_offset. -1 (the default) goes only with statement_start_offset 0: both mean every statement of the plan. | |
| statement_start_offset | No | With plan_handle, where the statement starts in its batch, as find_cached_queries or get_active_requests return it, to summarize that statement alone, with its statement_end_offset. Leave it at 0, and statement_end_offset at -1, for every statement of the plan. |