Skip to content

Commit de837d9

Browse files
authored
fix(db): earlier autovacuum on snapshots (#3368)
Applies the same per-table autovacuum override `env_builds` already received (20260723030000) to `public.snapshots`. **Why this is correct:** the change is a storage-parameter update only — it alters when autovacuum schedules a pass, never what any query reads or writes. It takes a brief ShareUpdateExclusive lock (no rewrite, no downtime) and is trivially revertible with `RESET`. **What it improves:** the default trigger fires only after dead tuples reach a fixed fraction of the table, and on a large table that means cleanup starts far too late — meanwhile every read of this table pays visibility checks against the accumulated dead row versions, so scan and lookup costs creep up between passes. This table sits on hot read paths (snapshot lookups during sandbox lifecycle operations), so keeping its dead-tuple population small keeps those paths at their baseline cost. Triggering earlier also makes each pass smaller and cheaper — frequent small vacuums instead of rare huge ones.
1 parent 2a8112a commit de837d9

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- +goose Up
2+
-- Same treatment env_builds received (20260723030000): the default autovacuum
3+
-- scale factors trigger a pass only after dead tuples reach a fixed fraction
4+
-- of the table, which on a large table defers cleanup far too long — index
5+
-- lookups pay visibility checks on the accumulated dead entries the whole
6+
-- time. Storage-parameter change only: takes a brief ShareUpdateExclusive
7+
-- lock, rewrites nothing, affects autovacuum scheduling alone.
8+
-- Inserts outnumber updates on this table, so the insert-driven threshold
9+
-- is lowered alongside the dead-tuple one: it keeps the visibility map
10+
-- fresh for the hot snapshot read paths between update-driven passes.
11+
ALTER TABLE public.snapshots SET (
12+
autovacuum_vacuum_scale_factor = 0.02,
13+
autovacuum_vacuum_insert_scale_factor = 0.02,
14+
autovacuum_analyze_scale_factor = 0.01
15+
);
16+
17+
-- +goose Down
18+
ALTER TABLE public.snapshots RESET (
19+
autovacuum_vacuum_scale_factor,
20+
autovacuum_vacuum_insert_scale_factor,
21+
autovacuum_analyze_scale_factor
22+
);

0 commit comments

Comments
 (0)