Skip to content

migrations: durable aggressive autovacuum for telemetry tables#89

Merged
thejefflarson merged 1 commit into
mainfrom
chore/telemetry-autovacuum
Jul 5, 2026
Merged

migrations: durable aggressive autovacuum for telemetry tables#89
thejefflarson merged 1 commit into
mainfrom
chore/telemetry-autovacuum

Conversation

@thejefflarson

Copy link
Copy Markdown
Owner

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, and spans: 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.sql sets 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 vacuum
  • autovacuum_vacuum_cost_limit = 2000 — let each run make real progress instead of throttling

These 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

  • No schema/DDL changes to columns or data — storage-parameter tuning only.
  • Table names verified against the schema: logs and spans (0001_init.sql), metric_series_rollups (0007).

🤖 Generated with Claude Code

https://claude.ai/code/session_013cYVqzH7Xfwea7fAozdQK7

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
@thejefflarson thejefflarson merged commit 753fcf8 into main Jul 5, 2026
4 checks passed
@thejefflarson thejefflarson deleted the chore/telemetry-autovacuum branch July 5, 2026 05:19
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