Skip to content

sp_QuickieStore: optimize representative text and plan fetch in @find_high_impact#709

Merged
erikdarlingdata merged 3 commits intodevfrom
feature/hi-perf-text-and-plan
Mar 24, 2026
Merged

sp_QuickieStore: optimize representative text and plan fetch in @find_high_impact#709
erikdarlingdata merged 3 commits intodevfrom
feature/hi-perf-text-and-plan

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

Two performance fixes based on actual execution plan analysis:

Representative text query (~23s → fast)

  • Moved query_id staging earlier (right after #hi_interesting)
  • Representative text now starts from #hi_id_staging_queries instead of scanning all 1.7M runtime stats rows through the full 4-table DMV chain

Final SELECT plan fetch (~29s → TBD)

  • Replaced TOP (1) ... ORDER BY with ROW_NUMBER() ... WHERE n = 1 in the OUTER APPLY to give the optimizer better plan choices for the correlated subquery

Test plan

  • SQL2022 — StackOverflow2013, hammerdb_tpch
  • SQL2016 — StackOverflow2010
  • Performance validation on larger Query Stores

🤖 Generated with Claude Code

erikdarlingdata and others added 3 commits March 23, 2026 18:42
sp_QuickieStore: optimize time bucketing in @find_high_impact
Representative text (ranked_hash, ~23s):
- Moved query_id staging to run immediately after #hi_interesting
- Representative text query now starts from #hi_id_staging_queries
  (pre-filtered interesting hashes) instead of scanning all runtime
  stats rows (1.7M → ~10K)

Final SELECT plan fetch (~29s):
- Replaced TOP (1) ... ORDER BY with ROW_NUMBER() ... WHERE n = 1
  in the OUTER APPLY to give the optimizer better options for the
  correlated subquery

Tested on SQL2022 (SO2013, TPC-H) and SQL2016 (SO2010).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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