Overview
Query Statistics is the query-centric performance review module. It helps you find the highest-impact queries, inspect source and execution plans, review deterministic scoring signals, run AI analysis, and pivot into related modules such as Wait Statistics or Index Advisor.
What You Can Do
- Rank queries by impact, latency, CPU, reads, executions, or risk.
- Inspect source code, query text, and execution plans.
- Review trend, regression, and plan stability signals.
- Run AI analysis for one query or a selected batch.
- Export, compare, and hand off findings for tuning work.
Main Screen Areas
- Query Store Health banner
- Filter toolbar
- Batch operations bar
- Results list
Data Source & Health
Preferred Source
The module prefers Query Store when it is available and healthy because it provides richer historical coverage.
- Query Store queries, plans, and runtime statistics
- More reliable trend and regression context
- Better depth for impact and stability analysis
Fallback Source
If Query Store is unavailable or unhealthy, the service can fall back to DMV-based data with more limited historical depth.
- sys.dm_exec_query_stats
- sys.dm_exec_sql_text
- sys.dm_exec_query_plan
Health Banner
- Green: Query Store is operational and recent.
- Yellow: Query Store is available but stale or partial.
- Red: Query Store is disabled, unavailable, or permission-blocked.
Why It Matters
- Fallback mode can reduce historical coverage.
- Missing permissions can limit source access or disable the module.
- Health and warning banners explain degraded or partial results.
Filters & Batch Controls
Filter Toolbar
- Duration: Last 24 Hours, Last 7 Days, Last 30 Days
- Order By: Impact Score, Average Duration, Total CPU, Execution Count, Logical Reads, Risk Score
- Limit: Top 500, 1000, 2000, or 5000
- Search: client-side filtering by query display name
- Reset to Defaults: restores per-database defaults and reloads the list
Visibility Controls
- Show System Queries is off by default.
- Show Sensitive Data is off by default and requires explicit confirmation.
- Filter state is persisted per active connection and database.
Batch Operations Bar
- Batch Operations
- Select Top 10 by CPU
- Clear Selection
- Selected: N counter
Batch Actions
- Analyze Selected with AI
- Export Selected to CSV
- Compare Selected Queries
- Batch AI currently analyzes only the first 10 selected queries.
Results List & Indicators
Query Cards
- Priority color bar and selection checkbox
- Query display name and optional CPU or IO flags
- Average duration, average CPU, executions, and plan count
- Last execution time, risk score, impact score, trend, and stability
Main Signals
- Impact Score prioritizes workload importance, not just latency.
- Trend % compares the current window with the prior window.
- Risk Score is a deterministic 0-100 signal.
- Stability is derived from plan count and variability.
Quick Actions
- View opens Source Code.
- Plan opens Execution Plan.
- AI and Details & Recommendations open AI Analysis.
- Related pivots into Wait Statistics.
- Watch pivots into Index Advisor.
Extra Actions
- Right-click opens module shortcuts such as missing indexes or wait analysis.
- A warning line appears for unstable multi-plan behavior.
- Load More fetches the next page when more results exist.
Query Detail Dialog
Header Controls
- Back returns to the list.
- Analyze with AI starts analysis for the current query.
- Cancel stops the current AI run when active.
- The header also shows AI status and query identity.
Tabs
- Source Code
- Execution Plan
- AI Analysis
Source & Plan Behavior
- Source first tries the object definition, then falls back to query text.
- Execution Plan loads and parses plan XML through the viewer.
- Plan tab can surface warnings or missing-index signals.
- When sensitive data is hidden, SQL literals and plan values are sanitized.
AI Analysis Output
- Shows context quality, bottleneck classification, and progress details.
- Provides Copy Text, Save Report, and Save LLM Request after successful runs.
- Report export formats include HTML, Markdown, and Text.
- LLM request export is available as JSON when present.
AI, Security & Practical Workflow
Sensitive Data Rules
- If sensitive data is off, the module uses redacted SQL and plan context.
- If sensitive data is on with a local provider, raw context can be used.
- If sensitive data is on with a cloud provider, the UI asks for explicit additional consent.
Permissions & Warnings
- VIEW SERVER STATE is required for full module functionality.
- Source viewing additionally depends on definition access.
- The warning banner surfaces fallback mode, stale Query Store, hidden system queries, and permission gaps.
Typical Workflow
- Review the Query Store Health banner first.
- Adjust Duration, Order By, Limit, and optional visibility settings.
- Search for the target query or object.
- Open View, Plan, or AI depending on the next question.
- Use Related or Watch to move into Wait Statistics or Index Advisor when needed.
- Export results or run batch actions for broader review.