LOB compression + deduplication for query stats tables (#419)#433
Merged
erikdarlingdata merged 1 commit intodevfrom Mar 5, 2026
Merged
LOB compression + deduplication for query stats tables (#419)#433erikdarlingdata merged 1 commit intodevfrom
erikdarlingdata merged 1 commit intodevfrom
Conversation
Databases were growing to 150-200 GB in under a week on busy servers.
LOB columns (query_text, query_plan_text, query_sql_text, compilation_metrics)
were 92-94% of storage. COMPRESS()/DECOMPRESS() achieves 90-91% reduction.
Schema changes:
- query_stats, query_store_data, procedure_stats: LOB columns changed from
nvarchar(max)/xml to varbinary(max) with COMPRESS() on write
- Dropped unused query_plan xml columns
- Added row_hash binary(32) for deduplication
- Added tracking tables (query_stats_latest_hash, procedure_stats_latest_hash,
query_store_data_latest_hash) for efficient hash lookups
Collector changes (08, 09, 10):
- COMPRESS() on all text/plan INSERT expressions
- collect_query/collect_plan flag support added to query_stats and procedure_stats
- HASHBYTES('SHA2_256', binary_concat) dedup: only INSERT rows where metrics changed
- MERGE source deduped with ROW_NUMBER() to prevent duplicate key errors
Read-side changes:
- All reporting views (46, 47) wrap compressed columns in DECOMPRESS()
- Dashboard C# queries updated with DECOMPRESS() in SQL strings
Upgrade path:
- Batched DELETE WITH OUTPUT migration compresses existing data in place
- IDENTITY reseed preserves ID continuity
- Old tables renamed to _old for safety (manual DROP later)
Version bump: 2.1.0 → 2.2.0 across all four projects.
Tested: clean install (sql2016), CLI upgrade (sql2017, sql2019, sql2022),
GUI upgrade (sql2025). All collectors healthy, dedup validated, all views
and MCP tools return readable decompressed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
query_text,query_plan_text,query_sql_text,compilation_metrics) — 90-91% storage reductionStorage reduction (sql2022)
Test plan
🤖 Generated with Claude Code