1VACUUMDB(1)              PostgreSQL 11.6 Documentation             VACUUMDB(1)
2
3
4

NAME

6       vacuumdb - garbage-collect and analyze a PostgreSQL database
7

SYNOPSIS

9       vacuumdb [connection-option...] [option...]
10                [ --table | -t table [( column [,...] )] ]...  [dbname]
11
12       vacuumdb [connection-option...] [option...] --all | -a
13

DESCRIPTION

15       vacuumdb is a utility for cleaning a PostgreSQL database.  vacuumdb
16       will also generate internal statistics used by the PostgreSQL query
17       optimizer.
18
19       vacuumdb is a wrapper around the SQL command VACUUM(7). There is no
20       effective difference between vacuuming and analyzing databases via this
21       utility and via other methods for accessing the server.
22

OPTIONS

24       vacuumdb accepts the following command-line arguments:
25
26       -a
27       --all
28           Vacuum all databases.
29
30       [-d] dbname
31       [--dbname=]dbname
32           Specifies the name of the database to be cleaned or analyzed. If
33           this is not specified and -a (or --all) is not used, the database
34           name is read from the environment variable PGDATABASE. If that is
35           not set, the user name specified for the connection is used.
36
37       -e
38       --echo
39           Echo the commands that vacuumdb generates and sends to the server.
40
41       -f
42       --full
43           Perform “full” vacuuming.
44
45       -F
46       --freeze
47           Aggressively “freeze” tuples.
48
49       -j njobs
50       --jobs=njobs
51           Execute the vacuum or analyze commands in parallel by running njobs
52           commands simultaneously. This option reduces the time of the
53           processing but it also increases the load on the database server.
54
55           vacuumdb will open njobs connections to the database, so make sure
56           your max_connections setting is high enough to accommodate all
57           connections.
58
59           Note that using this mode together with the -f (FULL) option might
60           cause deadlock failures if certain system catalogs are processed in
61           parallel.
62
63       -q
64       --quiet
65           Do not display progress messages.
66
67       -t table [ (column [,...]) ]
68       --table=table [ (column [,...]) ]
69           Clean or analyze table only. Column names can be specified only in
70           conjunction with the --analyze or --analyze-only options. Multiple
71           tables can be vacuumed by writing multiple -t switches.
72
73               Tip
74               If you specify columns, you probably have to escape the
75               parentheses from the shell. (See examples below.)
76
77       -v
78       --verbose
79           Print detailed information during processing.
80
81       -V
82       --version
83           Print the vacuumdb version and exit.
84
85       -z
86       --analyze
87           Also calculate statistics for use by the optimizer.
88
89       -Z
90       --analyze-only
91           Only calculate statistics for use by the optimizer (no vacuum).
92
93       --analyze-in-stages
94           Only calculate statistics for use by the optimizer (no vacuum),
95           like --analyze-only. Run several (currently three) stages of
96           analyze with different configuration settings, to produce usable
97           statistics faster.
98
99           This option is useful to analyze a database that was newly
100           populated from a restored dump or by pg_upgrade. This option will
101           try to create some statistics as fast as possible, to make the
102           database usable, and then produce full statistics in the subsequent
103           stages.
104
105       -?
106       --help
107           Show help about vacuumdb command line arguments, and exit.
108
109       vacuumdb also accepts the following command-line arguments for
110       connection parameters:
111
112       -h host
113       --host=host
114           Specifies the host name of the machine on which the server is
115           running. If the value begins with a slash, it is used as the
116           directory for the Unix domain socket.
117
118       -p port
119       --port=port
120           Specifies the TCP port or local Unix domain socket file extension
121           on which the server is listening for connections.
122
123       -U username
124       --username=username
125           User name to connect as.
126
127       -w
128       --no-password
129           Never issue a password prompt. If the server requires password
130           authentication and a password is not available by other means such
131           as a .pgpass file, the connection attempt will fail. This option
132           can be useful in batch jobs and scripts where no user is present to
133           enter a password.
134
135       -W
136       --password
137           Force vacuumdb to prompt for a password before connecting to a
138           database.
139
140           This option is never essential, since vacuumdb will automatically
141           prompt for a password if the server demands password
142           authentication. However, vacuumdb will waste a connection attempt
143           finding out that the server wants a password. In some cases it is
144           worth typing -W to avoid the extra connection attempt.
145
146       --maintenance-db=dbname
147           Specifies the name of the database to connect to discover what
148           other databases should be vacuumed. If not specified, the postgres
149           database will be used, and if that does not exist, template1 will
150           be used.
151

ENVIRONMENT

153       PGDATABASE
154       PGHOST
155       PGPORT
156       PGUSER
157           Default connection parameters
158
159       This utility, like most other PostgreSQL utilities, also uses the
160       environment variables supported by libpq (see Section 34.14).
161

DIAGNOSTICS

163       In case of difficulty, see VACUUM(7) and psql(1) for discussions of
164       potential problems and error messages. The database server must be
165       running at the targeted host. Also, any default connection settings and
166       environment variables used by the libpq front-end library will apply.
167

NOTES

169       vacuumdb might need to connect several times to the PostgreSQL server,
170       asking for a password each time. It is convenient to have a ~/.pgpass
171       file in such cases. See Section 34.15 for more information.
172

EXAMPLES

174       To clean the database test:
175
176           $ vacuumdb test
177
178       To clean and analyze for the optimizer a database named bigdb:
179
180           $ vacuumdb --analyze bigdb
181
182       To clean a single table foo in a database named xyzzy, and analyze a
183       single column bar of the table for the optimizer:
184
185           $ vacuumdb --analyze --verbose --table='foo(bar)' xyzzy
186

SEE ALSO

188       VACUUM(7)
189
190
191
192PostgreSQL 11.6                      2019                          VACUUMDB(1)
Impressum