agentsclimarketplace

Postgres queue health

Skill zacharygcook/agent-skills/skills/postgres-queue-health

A curated collection of practical, evidence-backed skills for coding agents.

Install
npx -y skills add zacharygcook/agent-skills --skill postgres-queue-health

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 28 days oldThe repository was created 28 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Review and diagnose Postgres-backed job queues for MVCC dead tuples, index bloat, autovacuum lag, long transactions, claim-query performance, retention, and SKIP LOCKED safety. Use when implementing, debugging, reviewing, or scaling database queues and their dashboards.

SKILL.md

3.3 KB, 651 tokens by cl100k_base, as published. Nobody here has run it

Postgres Queue Health

High-churn queue tables can slow down even when live queue depth stays flat. Updates and deletes create dead tuples; old snapshots delay cleanup; hot indexes retain dead entries; and claim workers repeatedly pay the visibility cost. FOR UPDATE SKIP LOCKED reduces worker blocking but does not solve bloat or retention.

Inspect the Claim Path

  • Confirm the claim query has a narrow queue/status/due-time predicate, bounded LIMIT, intentional ordering, and FOR UPDATE SKIP LOCKED where appropriate.
  • Compare partial-index predicates and column order with the actual filter and ordering.
  • Keep the claim transaction short. Commit the claim/update before external I/O or long job execution.
  • Bound batch claims and heartbeat frequency.
  • Use EXPLAIN (ANALYZE, BUFFERS) safely on representative, non-destructive queries.

Inspect Lifecycle and Storage

  • Separate hot claimable states from terminal history.
  • Add bounded cleanup, archive, or partitioning before succeeded/dead jobs dominate the table.
  • Keep dedupe and claim indexes free of terminal rows when possible.
  • Distinguish update-heavy tables from append-only attempt/event tables; their vacuum risks differ.
  • Check table and index growth alongside live/dead tuple estimates, not row count alone.

Inspect Vacuum and Transactions

  • Review table-level autovacuum thresholds for high-churn tables.
  • Find long-running and idle in transaction sessions that pin the MVCC horizon.
  • Compare last vacuum/autovacuum times, dead tuples, relation sizes, claim latency, and queue depth over time.
  • Do not recommend manual vacuum as a complete fix while an old transaction still prevents cleanup.

Inspect Read Paths

Keep dashboards and polling queries bounded, indexed, short, and read-only. Avoid broad analytics over hot queue history on the primary.

Starting Queries

SELECT relname, n_live_tup, n_dead_tup, last_autovacuum, last_vacuum
FROM pg_stat_user_tables
WHERE relname IN ('queue_jobs', 'queue_job_attempts');
SELECT now() - xact_start AS transaction_age, state, wait_event_type, wait_event, query
FROM pg_stat_activity
WHERE xact_start IS NOT NULL
ORDER BY xact_start ASC
LIMIT 20;
SELECT relname, pg_size_pretty(pg_total_relation_size(relid)) AS total_size
FROM pg_catalog.pg_statio_user_tables
WHERE relname IN ('queue_jobs', 'queue_job_attempts');

Adapt identifiers and predicates to the repository. Never run mutating maintenance against shared or production databases without explicit authorization.

Output

Report evidence, likely failure mode, claim/index alignment, retention risk, transaction risk, safe verification queries, and a low/medium/high severity. Separate observed facts from recommendations.

Further reading: Brandur Leach, “Postgres Job Queues & Failure By MVCC” and PlanetScale, “Keeping a Postgres queue healthy”.

What ships with it: 1 file

287 B alongside SKILL.md

agents/

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.