Skip to content

vacuum: dead tuples and autovacuum

Check dead tuples, autovacuum thresholds, running vacuums, and global switches in the current database.

Inspects sys_stat_user_tables, pg_class.reloptions, sys_stat_progress_vacuum, and autovacuum switches in the current database. Read-only: never executes VACUUM.

Usage

kbdiag vacuum
kbdiag vacuum --schema app --limit 20
kbdiag vacuum --all-schemas
kbdiag vacuum --json

Key Options

OptionEffect
--schema nameLimit tables to specific schema(s) (repeatable; conflicts with --all-schemas)
--all-schemasInclude system schemas such as sysmac, sys_hm, kdb_schedule
--limit NShow at most N tables (default 20, 0 for unlimited; judges all tables in scope)
--jsonEmit structured JSON (vacuum.tables, vacuum.progress, vacuum.settings)

Verdict & Reading Output

  • WARN (exit=1): vacuum.disabled (autovacuum or track_counts is off) or vacuum.table_disabled (table exceeded threshold + scale_factor * reltuples with autovacuum_enabled=off).
  • UNKNOWN (exit=3): vacuum.settings / vacuum.progress failed/skipped (including standby settings errors) or track_counts=off skipped table stats.
  • OK (exit=0): switches are on and no disabled table exceeds threshold; due=yes with autovacuum=on is normal queue behavior, not a fault. On standbys, table stats and running vacuums are not_applicable.

Example (KES V9 Primary, COLUMNS=80)

vacuum  WARN  (primary, system@local, endpoint=/tmp/.s.KINGBASE.54321, db=test,
    2026-12-02T15:48:39Z)
[FINDINGS]
  WARN vacuum.table_disabled: table kb_vac_day3.orders has 250 dead tuples,
    past its autovacuum threshold 130, but autovacuum is off for it
    (autovacuum_enabled=off): nothing will clean it
[SCOPE]
  schemas=non-system (current database; pass --schema or --all-schemas)
[SETTINGS]
  autovacuum    on  (3 workers, naptime 1m 0s)
  track_counts  on
  threshold     50 + 0.2 x reltuples
  No running vacuum operations observed
[TABLES IN TEST]
  2, most dead tuples first
  kb_vac_day3.orders  due=yes  autovacuum=off
    dead=250  live=400  threshold=130  last_auto=never  last_vac=never
  public.kbdiag_s1_lock_target  due=-  autovacuum=on
    dead=1  live=1  threshold=50  last_auto=never  last_vac=never
[NEXT]
  fix: VACUUM kb_vac_day3.orders  # connected to database test; requires table
    owner or superuser; turn autovacuum back on with ALTER TABLE ... RESET
    (autovacuum_enabled) unless it was turned off on purpose
  verify: kbdiag txn  # if dead tuples remain after VACUUM: the oldest
    transaction holding back the horizon
  verify: kbdiag slots  # or a replication slot's xmin
  • kbdiag freeze — XID / multixact age and wraparound headroom
  • kbdiag txn — oldest transaction holding back dead-tuple cleanup
  • kbdiag slots — replication slots retaining old xmin