PostgreSQL
databasepostgresqlReferenceIntermediate
Vacuum & Optimize PostgreSQL Database (vacuumdb)
Clean dead tuples, reclaim disk space, and update query planner statistics using the vacuumdb CLI tool.
Verified: 2026-09-30
Tested on:postgres 16.x
Platforms:
linuxmacoswindows
#postgresql#vacuumdb#maintenance#optimization#cli
Command
vacuumdb -h localhost -U postgres -d database_name -z -v
Short Description
vacuumdb is a command-line utility for cleaning and updating statistics for a PostgreSQL database.
Examples
1. Vacuum and Analyze All Tables in Database
vacuumdb -U postgres -d production_db --analyze --verbose2. Vacuum All Databases on Server
vacuumdb -U postgres --all --analyze --jobs=43. Full Table Lock Vacuum (Reclaims Disk to OS)
vacuumdb -U postgres -d production_db --full --table=large_audit_log