Skip to content

Add Query Store query-text search filter#390

Merged
erikdarlingdata merged 1 commit into
devfrom
feature/qs-query-text-search
Jul 16, 2026
Merged

Add Query Store query-text search filter#390
erikdarlingdata merged 1 commit into
devfrom
feature/qs-query-text-search

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

Summary

  • Adds a server-side query-text search to the Query Store integration, so users can find plans touching a specific table or statement fragment even when those plans aren't in the top N by the chosen metric — mirroring sp_QuickieStore's @query_text_search default behavior (requested in [FEATURE] Query text search #389).
  • The filter is applied pre-TOP-N in all three Query Store SQL builders (flat, grouped-by-hash, grouped-by-module), fully parameterized, and exposed with parity across all three surfaces: Desktop Search-by combo, MCP get_query_store_top, and the CLI query-store command.
  • Semantics match the proc's defaults exactly: input is trimmed and auto-wrapped in % when missing; %, _, [, ] remain live LIKE wildcards (bracket escaping is a possible follow-up, matching @escape_brackets).

Closes #389

Changes

  • Core: QueryStoreFilter.QueryTextSearch property + shared QueryStoreFilter.BuildQueryTextSearchPattern helper (QueryStorePlan.cs); identical parameterized EXISTS predicate against sys.query_store_query_text added to FetchTopPlansAsync and both grouped builders (QueryStoreService.cs, QueryStoreService.Grouped.cs). With the filter unset, generated SQL is byte-identical to before.
  • Desktop: "Query Text" item in the Search-by combo + one switch case (QueryStoreGridControl.axaml, QueryStoreGridControl.Filters.cs).
  • MCP: additive query_text_search parameter on get_query_store_top (named to avoid colliding with the tool's existing query_text output field).
  • CLI: additive --query-text-search option.
  • Tests: QueryTextSearchPatternTests.cs — full wrap/trim/wildcard/null matrix for the helper, plus backfilled coverage for the previously untested ParseExecutionType (22 new cases; 123 total pass).

Test Plan

  • dotnet build PlanViewer.sln -c Debug — no new warnings
  • dotnet test — 123/123 pass (101 existing + 22 new)
  • Live end-to-end on SQL Server 2022 / StackOverflow2013: unfiltered top-5 vs --query-text-search Votes return different query sets (proving pre-TOP-N filtering); no-match input exits cleanly with "no data"; returned query verified to match via substring (DownVotes)
  • planview query-store --help shows the new option with wildcard semantics
  • Desktop Search-by "Query Text" smoke (code-verified; UI not driven)

Generated with Claude Code

- QueryStoreFilter.QueryTextSearch + shared BuildQueryTextSearchPattern helper
  (sp_QuickieStore default semantics: trim, auto-wrap %, wildcards stay live)
- Parameterized EXISTS predicate applied pre-TOP-N in all three Query Store
  SQL builders (flat, grouped-by-hash, grouped-by-module)
- Desktop: Query Text option in the Search-by combo
- MCP: additive query_text_search param on get_query_store_top
- CLI: additive --query-text-search option
- Tests: helper pattern matrix + ParseExecutionType backfill (22 new cases)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@erikdarlingdata
erikdarlingdata merged commit 5a13d41 into dev Jul 16, 2026
2 checks passed
@erikdarlingdata
erikdarlingdata deleted the feature/qs-query-text-search branch July 16, 2026 22:32
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.

1 participant