migrations: durable aggressive autovacuum for telemetry tables#89
Merged
Conversation
The telemetry DB grew to 77 GB of dead-tuple bloat. The 7-day retention prune deletes rows fine, but at Postgres' default 20% autovacuum scale factor, autovacuum effectively never fired on the high-churn tables (logs, metric_series_rollups, spans): their insert+delete churn never crossed the 20%-of-table threshold, so dead tuples were never reclaimed. Lower the vacuum (and insert-triggered vacuum) scale factor to 2% and raise the cost limit so autovacuum keeps up with the prune's delete churn. These settings were already applied live via ALTER TABLE; this migration makes them durable across a DB recreate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013cYVqzH7Xfwea7fAozdQK7
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.
Why
The watcher telemetry DB grew to 77 GB of dead-tuple bloat. The 7-day retention prune deletes rows fine, but at Postgres' default 20% autovacuum scale factor, autovacuum effectively never fired on the high-churn tables
logs,metric_series_rollups, andspans: their steady insert+delete churn never crossed the 20%-of-table threshold before the table itself had grown, so dead tuples were never reclaimed.What
New migration
0013_telemetry_autovacuum.sqlsets aggressive per-table autovacuum on the three telemetry tables:autovacuum_vacuum_scale_factor = 0.02— vacuum at 2% dead tuples instead of 20%autovacuum_vacuum_insert_scale_factor = 0.02— same for insert-triggered vacuumautovacuum_vacuum_cost_limit = 2000— let each run make real progress instead of throttlingThese were already applied live via
ALTER TABLE, but that's imperative and wouldn't survive a DB recreate. This migration makes the tuning durable.Notes
logsandspans(0001_init.sql),metric_series_rollups(0007).🤖 Generated with Claude Code
https://claude.ai/code/session_013cYVqzH7Xfwea7fAozdQK7