mssql_manage_query
Analyze SQL Server query performance: explain execution plans, retrieve slow queries or query statistics, and reset plan cache/Query Store stats.
Instructions
Manage SQL Server query analysis and performance - operation="explain" for execution plans, operation="get_slow_queries" for slow query analysis (Query Store or plan cache), operation="get_stats" for query statistics, operation="reset_stats" for clearing statistics
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| costs | No | Accepted for compatibility; ignored | |
| limit | No | Number of queries to return (for get_slow_queries/get_stats operations) | |
| query | No | SQL query to explain (required for explain operation) | |
| format | No | Output format (for explain operation); json = XML plan plus extracted metrics | json |
| analyze | No | Actual plan (SET STATISTICS XML) - executes the query (for explain operation) | |
| buffers | No | Accepted for compatibility; ignored | |
| orderBy | No | Sort order (for get_slow_queries and get_stats operations) | mean_time |
| queryId | No | Specific query ID (Query Store query_id) or 0x plan_handle (plan cache) to reset; resets all if not provided | |
| verbose | No | Accepted for compatibility; ignored | |
| minCalls | No | Minimum number of calls (for get_stats operation) | |
| operation | Yes | Operation: explain (estimated or actual execution plan), get_slow_queries, get_stats (with cache hit ratios), reset_stats (clear plan cache / Query Store stats) | |
| minDuration | No | Minimum average duration in milliseconds (for get_slow_queries operation) | |
| queryPattern | No | Filter queries containing this pattern (for get_stats operation) | |
| connectionString | No | SQL Server connection string (optional; requires --allow-tool-connection-string) | |
| includeNormalized | No | Accepted for compatibility; ignored |