Skip to content

perf(job): unthrottle autovacuum on job_executions - #142

Merged
nicolasburtey merged 1 commit into
mainfrom
perf/job-executions-vacuum-cost-delay
Jul 29, 2026
Merged

perf(job): unthrottle autovacuum on job_executions#142
nicolasburtey merged 1 commit into
mainfrom
perf/job-executions-vacuum-cost-delay

Conversation

@nicolasburtey

Copy link
Copy Markdown
Member

Why

During a 1h, 10-loans/s-target lana-bank stress-test soak (sb-shard10bench sandbox, 2026-07-29), job_executions accumulated 13,893 dead tuples against 114 live rows despite the aggressive autovacuum triggers already in this migration (scale_factor = 0.01, threshold = 50). The poller's WITH due AS (...) query degraded from ~9 ms at startup to ~30 ms and stayed there.

The trigger thresholds were firing — the bottleneck was the default 2 ms vacuum_cost_delay throttle: each autovacuum run reclaimed dead tuples slower than the workload created them.

What

Adds autovacuum_vacuum_cost_delay = 0 to the existing per-table settings. The table is tiny (~100 live rows), so unthrottled vacuum runs are cheap and keep dead tuples near zero, holding the poll query's cost flat.

Mirrors GaloyMoney/lana-bank#7675, which carries the same change in lana-bank's vendored copy of this migration (files verified identical).

Evidence

  • pg_stat_user_tables: n_live_tup = 114, n_dead_tup = 13,893
  • pg_stat_statements (job poll, queryid -7391300573923152793): mean 9.2 ms (startup) → 30.1 ms (T+25min) → 27.5 ms (T+1h)

The job_executions table already had aggressive autovacuum triggers
(scale_factor 0.01, threshold 50), but under a 10 loans/s stress-test
soak in lana-bank it still accumulated 13.9k dead tuples against 114
live rows, and the poller's WITH due AS (...) query degraded from ~9ms
at startup to ~30ms within an hour. The trigger thresholds were
firing; the default 2ms vacuum cost delay throttled each run so
reclaim could not keep up with the churn rate.

Set autovacuum_vacuum_cost_delay = 0 for this table. It is tiny
(~100 live rows), so unthrottled vacuums are cheap and keep dead
tuples near zero, holding the poll query's cost flat.

Mirrors GaloyMoney/lana-bank#7675.
@nicolasburtey
nicolasburtey marked this pull request as ready for review July 29, 2026 22:38
@nicolasburtey
nicolasburtey merged commit 6c9209f into main Jul 29, 2026
4 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