Skip to content

sp_QuickieStore: rewrite representative text query for @find_high_impact#702

Merged
erikdarlingdata merged 2 commits intomainfrom
dev
Mar 23, 2026
Merged

sp_QuickieStore: rewrite representative text query for @find_high_impact#702
erikdarlingdata merged 2 commits intomainfrom
dev

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

Rewrites the representative text query to group by query_hash + query_text_id (fixed-width) instead of query_hash + query_sql_text (nvarchar(max)), then joins text only for the winner. Eliminates expensive Hash Aggregate on large string data.

Tested on SQL2022 and SQL2016.

🤖 Generated with Claude Code

erikdarlingdata and others added 2 commits March 23, 2026 15:36
…on nvarchar(max)

The #hi_representative_text query grouped by query_hash + query_sql_text,
forcing the Hash Aggregate to hash nvarchar(max) values. Rewritten to
group by query_hash + query_text_id (both fixed-width) in a subquery,
then join back to query_store_query_text only for the rn=1 winner.

Tested on SQL2022 and SQL2016.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sp_QuickieStore: rewrite representative text query to avoid grouping on nvarchar(max)
@erikdarlingdata erikdarlingdata merged commit 19a231b into main Mar 23, 2026
9 checks passed
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