July 28, 2021

vacuumdb utility commands in PostgreSQL

PostgreSQL vacuumdb utility commands


vacuumdb  - utility for cleaning/analyzing PostgreSQL database. Will also generate internal statistics used by the PostgreSQL query optimizer.

vacuumdb --version

vacuumdb proddb
vacuumdb -U postgres -d testdb
vacuumdb -U postgres -a

vacuumdb -f proddb # full vacuum
vacuumdb -U postgres -d testdb -f -v
vacuumdb -U postgres -a -f --verbose

vacuumdb -F # Vacuum freeze
vacuumdb -Z proddb
vacuumdb -z proddb  --echo
vacuumdb -az
vacuumdb -azf

nohup vacuumdb -f -d empown -h testdb.cluster-***.us-east-2.rds.amazonaws.com -p5432 -U dbadmin -v &
nohup vacuumdb --full --analyze --dbname empown --host testdb.cluster-***.us-east-2.rds.amazonaws.com --port5432 --username dbadmin --verbose &

vacuumdb --help
Usage:
  vacuumdb [OPTION]... [DBNAME]

Options:
  -a, --all                       vacuum all databases
  -d, --dbname=DBNAME             database to vacuum
      --disable-page-skipping     disable all page-skipping behavior
  -e, --echo                      show the commands being sent to the server
  -f, --full                      do full vacuuming
  -F, --freeze                    freeze row transaction information
      --force-index-cleanup       always remove index entries that point to dead tuples
  -j, --jobs=NUM                  use this many concurrent connections to vacuum
      --min-mxid-age=MXID_AGE     minimum multixact ID age of tables to vacuum
      --min-xid-age=XID_AGE       minimum transaction ID age of tables to vacuum
      --no-index-cleanup          don't remove index entries that point to dead tuples
      --no-process-toast          skip the TOAST table associated with the table to vacuum
      --no-truncate               don't truncate empty pages at the end of the table
  -P, --parallel=PARALLEL_WORKERS use this many background workers for vacuum, if available
  -q, --quiet                     don't write any messages
      --skip-locked               skip relations that cannot be immediately locked
  -t, --table='TABLE[(COLUMNS)]'  vacuum specific table(s) only
  -v, --verbose                   write a lot of output
  -V, --version                   output version information, then exit
  -z, --analyze                   update optimizer statistics
  -Z, --analyze-only              only update optimizer statistics; no vacuum
      --analyze-in-stages         only update optimizer statistics, in multiple stages for faster results; no vacuum
  -?, --help                      show this help, then exit

Connection options:
  -h, --host=HOSTNAME       database server host or socket directory
  -p, --port=PORT           database server port
  -U, --username=USERNAME   user name to connect as
  -w, --no-password         never prompt for password
  -W, --password            force password prompt
  --maintenance-db=DBNAME   alternate maintenance database


Related PostgreSQL Articles: pg_dumpall commands in PostgreSQL

No comments:

Post a Comment