tuning-autovacuum-and-bloat

tuning-autovacuum-and-bloat is a skill for Claude Code from pumarogie/claude-postgres-skills. It costs 52 tokens per session (1,096 once invoked), scanned A, original, MIT.

A guide to PostgreSQL autovacuum and database bloat. Autovacuum cleans up old row versions left by updates and deletes, while bloat is wasted table or index space caused by that buildup.

In plain words
What is it for?
Finding tables with many dead rows, checking cleanup blockers, and tuning vacuum behavior for high-write tables.
Why use it?
It helps prevent cleanup from falling behind, disk usage from growing unnecessarily, and old transaction IDs from becoming unsafe.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the database-skill plugin — 6 skills shipped together

Good fit Finding tables with many dead rows, checking cleanup blockers, and tuning vacuum behavior for high-write tables.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pumarogie/claude-postgres-skills/tuning-autovacuum-and-bloat
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add pumarogie/claude-postgres-skills --skill tuning-autovacuum-and-bloat
Clone the repo
git clone --depth 1 https://github.com/pumarogie/claude-postgres-skills

Made for: Claude Code.

Or install database-skill, the plugin that ships this one along with the rest of its 6 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tuning-autovacuum-and-bloat

README.md
[![agentmods](https://agentmods.dev/badge/skills/pumarogie/claude-postgres-skills/tuning-autovacuum-and-bloat/github.svg)](https://agentmods.dev/skills/pumarogie/claude-postgres-skills/tuning-autovacuum-and-bloat)
Your own site
<a href="https://agentmods.dev/skills/pumarogie/claude-postgres-skills/tuning-autovacuum-and-bloat"><img src="https://agentmods.dev/badge/skills/pumarogie/claude-postgres-skills/tuning-autovacuum-and-bloat/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tuning-autovacuum-and-bloat

Your own site · 80×15
<a href="https://agentmods.dev/skills/pumarogie/claude-postgres-skills/tuning-autovacuum-and-bloat"><img src="https://agentmods.dev/badge/skills/pumarogie/claude-postgres-skills/tuning-autovacuum-and-bloat.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,096 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.01096
Opus 5 $0.00026 $0.00548
Sonnet 5 $0.00010 $0.00219
Haiku 4.5 $0.00005 $0.00110

Measured 11d ago against content hash 0e0ca7800c77, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

tuning-autovacuum-and-bloat scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/tuning-autovacuum-and-bloat/SKILL.md · 80 lines

How it starts

The opening of the file, as written. The whole thing — 80 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Tuning Autovacuum and Bloat

Overview

UPDATE and DELETE leave dead row versions. Vacuum makes their space reusable and freezes old transaction IDs; it usually does not return table space to the filesystem. Tune per high-write table before dead tuples, index churn, or transaction-ID age becomes an incident.

Diagnose before rewriting

SELECT schemaname, relname, n_live_tup, n_dead_tup,
       last_autovacuum, autovacuum_count,
       last_autoanalyze, autoanalyze_count
FROM pg_stat_user_tables
ORDER BY n_dead_tup DESC
LIMIT 20;

Statistics are estimates. Check write rate, vacuum progress, long-running transactions, replica feedback, and disk growth together. A long vacuum is not automatically unhealthy if it is making progress and transaction-ID age remains safe.

Always look for cleanup blockers: long-running transactions, abandoned idle in transaction sessions, old replication slots, and standby feedback. These can hold back the oldest removable row version even when autovacuum runs.

Start with per-table tuning

Large busy tables should not wait for a large fraction of all rows to change. A concrete starting point—not a universal optimum—is:

ALTER TABLE events SET (
  autovacuum_vacuum_scale_factor = 0.01,
  autovacuum_vacuum_threshold = 1000,
  autovacuum_vacuum_cost_limit = 2000
);

This requests vacuum after roughly 1% of estimated rows plus 1,000 changes and gives that table more work budget per cost-delay cycle. Measure I/O and vacuum duration, then tune one step at a time. On very large tables, derive the scale factor from the maximum dead tuples you can tolerate rather than copying a percentage.

Concrete parameter guidance, progress queries, and transaction-ID monitoring: reference/autovacuum-settings-and-wraparound.md.

Prevent wraparound

Measure both table and database age, and compare it with the configured setting:

SELECT c.oid::regclass, age(c.relfrozenxid) AS xid_age,
       current_setting('autovacuum_freeze_max_age')::bigint AS freeze_max_age
FROM pg_class AS c WHERE c.relkind IN ('r', 'm')
ORDER BY age(c.relfrozenxid) DESC;

SELECT datname, age(datfrozenxid) AS xid_age
FROM pg_database ORDER BY age(datfrozenxid) DESC;

Read the full file on GitHub · 80 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 80 lines · 52 tokens per session scan A 0e0ca7800c77

Subscribe to this mod's changes

tuning-autovacuum-and-bloat is a skill published in the GitHub repository pumarogie/claude-postgres-skills (2 stars, last pushed 1mo ago), licensed MIT. It adds 52 tokens to every session and 1,096 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

database-optimizer

Optimizes database queries and improves performance across PostgreSQL and MySQL systems. Use when investigating slow queries, analyzing execution plans, or optimizing database performance. Invoke for index design, query rewrites, configuration tuning, partitioning strategies, lock contention resolution.

Jeffallan/claude-skills · 54 tokens

postgres-pro

Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.

Jeffallan/claude-skills · 41 tokens

postgres-database-migration

Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases. Trigger when user asks to: Test a schema migration before applying it to production Add, remove, or rename columns safely on a live table Change a column's data…

timescale/pg-aiguide · 220 tokens

setup-timescaledb-hypertables

Use this skill when creating database schemas or tables for Timescale, TimescaleDB, TigerData, or Tiger Cloud, especially for time-series, IoT, metrics, events, or log data. Use this to improve the performance of any insert-heavy table. Trigger when user asks to: Create or design SQL schemas/tables AND…

timescale/pg-aiguide · 219 tokens

design-postgis-tables

Comprehensive PostGIS spatial table design reference covering geometry types, coordinate systems, spatial indexing, and performance patterns for location-based applications.

timescale/pg-aiguide · 31 tokens

migrate-postgres-tables-to-hypertables

Use this skill to migrate identified PostgreSQL tables to Timescale/TimescaleDB hypertables with optimal configuration and validation. Trigger when user asks to: Migrate or convert PostgreSQL tables to hypertables Execute hypertable migration with minimal downtime Plan blue-green migration for large tables Validate…

timescale/pg-aiguide · 181 tokens