Skip to content

Add log-to-table for sp_QuickieStore#762

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/quickiestore-log-to-tables
Apr 15, 2026
Merged

Add log-to-table for sp_QuickieStore#762
erikdarlingdata merged 1 commit intodevfrom
feature/quickiestore-log-to-tables

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • Adds @log_to_table, @log_database_name, @log_schema_name, @log_table_name_prefix, @log_retention_days parameters following the sp_HealthParser logging pattern
  • When @log_to_table = 1, results INSERT into 9 permanent tables instead of returning to the client — enables scheduled/automated Query Store analysis
  • Tables: RuntimeStats, CompilationStats, ResourceStats, WaitStatsByQuery, WaitStatsTotal, PlanFeedback, QueryHints, QueryVariants, QueryStoreOptions
  • Forces @format_output = 0 when logging (raw numeric storage for analysis)
  • Mutually exclusive with @find_high_impact (RAISERROR + RETURN)
  • Includes retention cleanup, schema auto-creation, IF NOT EXISTS table creation

Test plan

  • Compiles clean on SQL2016, SQL2017, SQL2019, SQL2022, SQL2025
  • Normal mode logging populates RuntimeStats only
  • Expert mode logging populates all 9 tables
  • @log_to_table + @find_high_impact raises error
  • @format_output = 1 with logging stores raw float values (override works)
  • No result sets returned when logging (mutually exclusive)
  • Normal mode (no logging) unchanged — regression test passes all 5 servers
  • Expert mode tested against StackOverflow2010 (QS enabled) on all 5 servers
  • SQL2016 correctly gets 0 wait stats rows (feature unavailable pre-2017)
  • Help text updated for all 5 new parameters
  • Debug output includes new parameters

🤖 Generated with Claude Code

Adds 5 new parameters (@log_to_table, @log_database_name, @log_schema_name,
@log_table_name_prefix, @log_retention_days) following the sp_HealthParser
logging pattern. When @log_to_table = 1, results are inserted into permanent
tables instead of returned to the client, enabling scheduled/automated
Query Store analysis.

- 9 logging tables: RuntimeStats, CompilationStats, ResourceStats,
  WaitStatsByQuery, WaitStatsTotal, PlanFeedback, QueryHints,
  QueryVariants, QueryStoreOptions
- Forces @format_output = 0 when logging (raw numeric storage)
- Mutually exclusive with @find_high_impact
- Includes retention cleanup, schema auto-creation, and IF NOT EXISTS
  table creation
- Tested across SQL2016-SQL2025

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit ca2dbd8 into dev Apr 15, 2026
5 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