Skip to content

Feature/statistics summary#90

Open
Blake-goofy wants to merge 4 commits intoAxial-SQL:mainfrom
Blake-goofy:feature/statistics-summary
Open

Feature/statistics summary#90
Blake-goofy wants to merge 4 commits intoAxial-SQL:mainfrom
Blake-goofy:feature/statistics-summary

Conversation

@Blake-goofy
Copy link
Copy Markdown
Contributor

@Blake-goofy Blake-goofy commented May 7, 2026

Statistics Summary for SET STATISTICS IO/TIME output

Why I made this

When I am writing SQL, I often want to compare two ways to write the same query. Using SET STATISTICS IO ON; is one of the best ways to see which version is better because it shows how many reads SQL Server had to do. When a query is slow, the table-by-table breakdown can also help point to the part of the query that needs attention.

The problem is that the raw statistics output in SSMS is just a dense block of text. It is hard to scan, and if a table appears multiple times you have to manually add those reads together to understand the real total. This change solves that by summarizing the output and presenting it in a much more user-friendly way.

What this adds

This PR adds a new Statistics Summary tool window in Axial SQL Tools.

The window captures the most recent visible SET STATISTICS IO and optional SET STATISTICS TIME output, parses it, and displays:

  • Total reads across the execution
  • Total elapsed time
  • Total CPU time
  • Reads per table
  • Scan count per table
  • Source connection and database
  • The source query in a collapsed, scrollable panel

This makes it much easier to compare query rewrites, spot which tables are driving IO, and understand where to focus tuning effort.

Screenshot

image

Behavior and implementation notes

  • The Statistics Summary window only does work while the window is actually open and visible.
  • If the window is not visible, executions are intentionally ignored instead of doing background capture work the user cannot see.
  • The capture can be canceled while it is loading.
  • The source query is hidden by default and can be expanded when needed.
  • SET STATISTICS TIME ON; is optional. If time output is present, elapsed time and CPU time are included in the summary.

Considerations during implementation

  • SSMS does not always expose the statistics messages immediately when execution finishes, so the capture logic retries briefly instead of assuming the text is available right away.
  • The window lifecycle mattered more than expected. The implementation had to be careful about open, close, and reopen behavior so the feature keeps working across repeated uses in the same SSMS session.
  • I intentionally avoid keeping capture active when the window is hidden because that would add overhead without giving the user a visible result.
  • The UI is focused on the most actionable information first: totals at the top, then table-level breakdown, then the source query if you want to inspect it.

Note about the .vscode files

This PR also includes .vscode files that I use for local development in VS Code.

  • They are not directly related to the Statistics Summary feature itself.
  • I added them because I use VS Code to build and reinstall the extension during development.
  • They were included in a separate commit to make them easy to review independently or exclude from the PR if the repo should not keep those files.

How to test

  1. Open SSMS with the updated extension installed.
  2. Open the Statistics Summary window from Axial SQL Tools.
  3. Run a query that includes SET STATISTICS IO ON;.
  4. Optionally also include SET STATISTICS TIME ON; if you want elapsed time and CPU time included.
  5. Execute a query that touches one or more tables.
  6. Confirm the window updates with total reads, table-level reads, and scan counts.
  7. If SET STATISTICS TIME ON; was included, confirm elapsed time and CPU time are shown.
  8. Confirm the source query is available in the collapsed Source query section and can be expanded and scrolled.
  9. While a capture is still loading, click Cancel and confirm the loading state stops.
  10. Close or hide the window, execute another query, then reopen it and confirm the feature only reflects executions that happened while the window was visible.
  11. Reopen the window after closing it and execute again to confirm capture still works after close and reopen.

Expected outcome

Reviewers should be able to see that this feature turns hard-to-read SSMS statistics text into a practical tuning view that is useful for comparing query approaches and identifying which tables are responsible for the most reads.

Copilot AI review requested due to automatic review settings May 7, 2026 02:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Statistics Summary” tool window to Axial SQL Tools that captures the latest visible SET STATISTICS IO (and optional SET STATISTICS TIME) output from SSMS, parses it, and presents totals plus per-table breakdowns for easier query tuning/comparisons.

Changes:

  • Introduces a new tool window (XAML + view model) and a backing store for loading/capture state.
  • Implements parsing for SET STATISTICS IO/TIME text and wires capture into SSMS execution events via GridAccess/package hooks.
  • Adds a VSCT command + icon, project file inclusions, and optional local .vscode build/reinstall tasks.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
AxialSqlTools/StatisticsSummary/StatisticsSummaryWindowControl.xaml.cs Tool window control lifecycle, store subscription, and UI refresh wiring
AxialSqlTools/StatisticsSummary/StatisticsSummaryWindowControl.xaml Statistics Summary UI layout (totals, table grid, source info/query expander)
AxialSqlTools/StatisticsSummary/StatisticsSummaryWindowCommand.cs Command to open the Statistics Summary tool window
AxialSqlTools/StatisticsSummary/StatisticsSummaryWindow.cs Tool window pane + frame notifications for open/close lifecycle
AxialSqlTools/StatisticsSummary/StatisticsSummaryViewModel.cs View model that formats store/summary data for the UI
AxialSqlTools/StatisticsSummary/StatisticsSummaryStore.cs Shared state store for summary + capture/loading flags
AxialSqlTools/StatisticsSummary/StatisticsSummaryParser.cs Regex-based parsing of STATISTICS IO/TIME output into a summary model
AxialSqlTools/StatisticsSummary/StatisticsSummary.cs Summary/table model types used by parser/store/view model
AxialSqlTools/Modules/GridAccess.cs Reflection-based retrieval/flush of SSMS statistics text from results/messages surfaces
AxialSqlTools/AxialSqlToolsPackage.vsct Adds the Statistics Summary menu command + icon registration
AxialSqlTools/AxialSqlToolsPackage.cs Hooks execution events and implements capture/retry/cancel logic feeding the store
AxialSqlTools/AxialSqlTools.csproj Includes new Statistics Summary files and runtime identifier properties
.vscode/tasks.json Local tasks for building and reinstalling the extension
.vscode/axial-extension.ps1 Local PowerShell automation for build/reinstall via MSBuild/VSIXInstaller

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AxialSqlTools/StatisticsSummary/StatisticsSummaryWindow.cs
Comment thread AxialSqlTools/StatisticsSummary/StatisticsSummaryParser.cs
Comment thread AxialSqlTools/StatisticsSummary/StatisticsSummaryParser.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants