Last updated: 2025-05-10 14:16:59 UTC
\c your_db your_writer_user
VACUUM ANALYZE;
β οΈ If you seepermission denied
, you need to connect as a user with elevated rights.
SELECT
current_database() AS db,
COUNT(*) FILTER (
WHERE last_vacuum IS NULL OR last_analyze IS NULL
) AS tables_not_vacuumed,
COUNT(*) AS total_tables
FROM
pg_stat_user_tables;
SELECT relname, last_vacuum, last_analyze
FROM pg_stat_user_tables
ORDER BY last_analyze DESC;
SHOW autovacuum;
SHOW autovacuum_vacuum_threshold;
SHOW autovacuum_analyze_threshold;
SHOW autovacuum_vacuum_scale_factor;
SHOW autovacuum_analyze_scale_factor;
For each database:
psql -U your_writer_user -d dbname -h writer.cluster-xyz.rds.amazonaws.com -c "VACUUM ANALYZE;"
Or interactively inside psql:
\c dbname your_writer_user
VACUUM ANALYZE;
Create ~/.pgpass
with:
your-host:5432:*:your_writer_user:yourpassword
Then:
chmod 600 ~/.pgpass