vacuumdb

A core utility for vacuuming and analyzing PostgreSQL

vacuumdb is a core utility for vacuuming and analyzing PostgreSQL.

vacuumdb was added in PostgreSQL 7.0.

Usage

vacuumdb is effectively a command-line wrapper around the VACUUM and ANALYZE commands, with additional convenience functionality for:

  • running ANALYZE in incremental stages (--analyze-in-stages option)
  • vacuuming all databases in a single pass (--all option)

vacuumdb --all option

Somewhat counterintuitively, vacuumdb rejects the -d/--dbname option when --all is specified:

$ vacuumdb --all --analyze-in-stages -d 'host=node1 port=5433'
vacuumdb: error: cannot vacuum all databases and a specific one at the same time

In this case use the --maintenance-db option to provide an explicit database name or conninfo string.

Source code

The vacuumdb source code is located at src/bin/scripts/vacuumdb.c.

Change history

Examples

$ vacuumdb --all --analyze-in-stages
vacuumdb: processing database "contentdb": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "contentdb": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "contentdb": Generating default (full) optimizer statistics
vacuumdb: processing database "postgres": Generating default (full) optimizer statistics
vacuumdb: processing database "template1": Generating default (full) optimizer statistics

Categories

Core utility, Vacuuming

See also

vacuumlo, VACUUM, ANALYZE, clusterdb