Check autovacuum status

Find tables with dead tuples and stale autovacuum runs

SELECT relname, n_dead_tup, last_autovacuum, last_autoanalyze FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 20;

tool
postgres29 commands
tags
postgresperformancemonitoringtroubleshooting

More postgres commands

  • REINDEX INDEX CONCURRENTLY <name>; -- note: cannot run inside a transaction block

    Rebuild a bloated index online; note: must run outside a transaction

  • CREATE INDEX CONCURRENTLY idx_<name> ON <table>(col); -- monitor: SELECT * FROM pg_stat_progress_create_index;

    Build index without blocking writes; track progress via pg_stat_progress_create_index

  • pg_dump -Fc -j 4 -d <name> -f db.dump && pg_restore -j 4 -d <name> db.dump

    Custom-format parallel dump/restore; note: -j needs directory or custom format, not plain SQL

  • pgbench -c 32 -j 8 -T 60 -P 5 -d <name>; -- init once: pgbench -i -s 100 <name>

    Run 60s load test with 32 clients across 8 threads, progress every 5s

  • psql -h localhost -U myuser -d mydb

    Interactive psql session to a database

all 29 postgres commands