vacuumdb
Garbage-collects and analyzes a database.
Synopsis
vacuumdb [ <connection-option> ... ]
[ --full | -f ]
[ --freeze | -F ]
[ --verbose | -v ]
[ --analyze | -z ]
[ --analyze-only | -Z ]
[ --table | -t <table> [ ( <column> [ , ... ] ) ] ]
[ <dbname> ]
vacuumdb [ <connection-option> ... ]
[ --all | -a ]
[ --full | -f ]
[ --freeze | -F ]
[ --verbose | -v ]
[ --analyze | -z ]
[ --analyze-only | -Z ]
vacuumdb -? | --help
vacuumdb -V | --version
Description
vacuumdb is a utility for cleaning a Greengage DB database.
vacuumdb will also generate internal statistics used by the Greengage DB query optimizer.
vacuumdb is a wrapper around the SQL command VACUUM.
There is no effective difference between vacuuming databases via this utility and via other methods for accessing the server.
Options
- -a | --all
-
Vacuum all databases.
- [-d] <dbname> | [--dbname=]<dbname>
-
The name of the database to vacuum. If this is not specified and
-a(or--all) is not used, the database name is read from the environment variablePGDATABASE. If that is not set, the user name specified for the connection is used. - -e | --echo
-
Echo the commands that
vacuumdbgenerates and sends to the server. - -f | --full
-
Perform a full vacuum, which can reclaim more space, but takes much longer and exclusively locks the table.
CAUTIONA
VACUUM FULLis not recommended in Greengage DB. - -F | --freeze
-
Freeze row transaction information.
- -q | --quiet
-
Do not display a response.
- -t <table> [(<column>)] | --table=<table> [(<column>)]
-
Clean or analyze this table only. Column names may be specified only in conjunction with the
--analyzeor--analyze-onlyoptions. Multiple tables can be vacuumed by writing multiple-tswitches. If you specify columns, you probably have to escape the parentheses from the shell. - -v | --verbose
-
Print detailed information during processing.
- -z | --analyze
-
Collect statistics for use by the query planner.
- -Z | --analyze-only
-
Only calculate statistics for use by the query planner (no vacuum).
- --analyze-in-stages
-
Only update optimizer statistics, in multiple stages for faster results.
- -V | --version
-
Print the
vacuumdbversion and exit. - -? | --help
-
Show help about
vacuumdbcommand line arguments, and exit.
Connection options
- -h <host> | --host=<host>
-
The host name of the machine on which the Greengage DB master is running. If not specified, reads from the
PGHOSTenvironment variable or defaults tolocalhost. - -p <port> | --port=<port>
-
The TCP port on which the Greengage DB master is listening for connections. If not specified, reads from the
PGPORTenvironment variable or defaults to5432. - -U <username> | --username=<username>
-
The database role name to connect as. If not specified, reads from the environment variable
PGUSERor defaults to the current system user name. - -w | --no-password
-
Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.
- -W | --password
-
Force a password prompt.
- --maintenance-db=<dbname>
-
The name of the database to connect to discover what other databases should be vacuumed. If not specified, the
postgresdatabase will be used, and if that does not exist,template1will be used.
Notes
vacuumdb might need to connect several times to the master server, asking for a password each time.
It is convenient to have a ~/.pgpass file in such cases.
Examples
Clean the test database:
$ vacuumdb test
Clean and analyze a database named bigdb:
$ vacuumdb --analyze bigdb
Clean and analyze the foo table in a database named mydb, specifically analyzing column bar of the table.
Note the quotes around the table and column names to escape the parentheses from the shell:
$ vacuumdb --analyze --verbose --table 'foo(bar)' mydb