2
doc/src/sgml/ref/vacuumdb.sgml
3
PostgreSQL documentation
6
<refentry id="APP-VACUUMDB">
8
<refentrytitle><application>vacuumdb</application></refentrytitle>
9
<manvolnum>1</manvolnum>
10
<refmiscinfo>Application</refmiscinfo>
14
<refname id="vacuumdb">vacuumdb</refname>
15
<refpurpose>garbage-collect and analyze a <productname>PostgreSQL</productname> database</refpurpose>
18
<indexterm zone="app-vacuumdb">
19
<primary>vacuumdb</primary>
24
<command>vacuumdb</command>
25
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
26
<group><arg>--full</arg><arg>-f</arg></group>
27
<group><arg>--freeze</arg><arg>-F</arg></group>
28
<group><arg>--verbose</arg><arg>-v</arg></group>
29
<group><arg>--analyze</arg><arg>-z</arg></group>
30
<group><arg>--analyze-only</arg><arg>-Z</arg></group>
31
<arg>--table | -t <replaceable>table</replaceable>
32
<arg>( <replaceable class="parameter">column</replaceable> [,...] )</arg>
34
<arg><replaceable>dbname</replaceable></arg>
38
<command>vacuumdb</command>
39
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
40
<group><arg>--full</arg><arg>-f</arg></group>
41
<group><arg>--freeze</arg><arg>-F</arg></group>
42
<group><arg>--verbose</arg><arg>-v</arg></group>
43
<group><arg>--analyze</arg><arg>-z</arg></group>
44
<group><arg>--analyze-only</arg><arg>-Z</arg></group>
45
<group><arg>--all</arg><arg>-a</arg></group>
50
<title>Description</title>
53
<application>vacuumdb</application> is a utility for cleaning a
54
<productname>PostgreSQL</productname> database.
55
<application>vacuumdb</application> will also generate internal statistics
56
used by the <productname>PostgreSQL</productname> query optimizer.
60
<application>vacuumdb</application> is a wrapper around the SQL
61
command <xref linkend="SQL-VACUUM">.
62
There is no effective difference between vacuuming and analyzing
63
databases via this utility and via other methods for accessing the
71
<title>Options</title>
74
<application>vacuumdb</application> accepts the following command-line arguments:
77
<term><option>-a</option></term>
78
<term><option>--all</option></term>
87
<term><option><optional>-d</> <replaceable class="parameter">dbname</replaceable></option></term>
88
<term><option><optional>--dbname=</><replaceable class="parameter">dbname</replaceable></option></term>
91
Specifies the name of the database to be cleaned or analyzed.
92
If this is not specified and <option>-a</option> (or
93
<option>--all</option>) is not used, the database name is read
94
from the environment variable <envar>PGDATABASE</envar>. If
95
that is not set, the user name specified for the connection is
102
<term><option>-e</></term>
103
<term><option>--echo</></term>
106
Echo the commands that <application>vacuumdb</application> generates
107
and sends to the server.
113
<term><option>-f</option></term>
114
<term><option>--full</option></term>
117
Perform <quote>full</quote> vacuuming.
123
<term><option>-F</option></term>
124
<term><option>--freeze</option></term>
127
Aggressively <quote>freeze</quote> tuples.
133
<term><option>-q</></term>
134
<term><option>--quiet</></term>
137
Do not display progress messages.
143
<term><option>-t <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</option></term>
144
<term><option>--table=<replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</option></term>
147
Clean or analyze <replaceable class="parameter">table</replaceable> only.
148
Column names can be specified only in conjunction with
149
the <option>--analyze</option> or <option>--analyze-only</option> options.
153
If you specify columns, you probably have to escape the parentheses
154
from the shell. (See examples below.)
161
<term><option>-v</option></term>
162
<term><option>--verbose</option></term>
165
Print detailed information during processing.
171
<term><option>-V</></term>
172
<term><option>--version</></term>
175
Print the <application>vacuumdb</application> version and exit.
181
<term><option>-z</option></term>
182
<term><option>--analyze</option></term>
185
Also calculate statistics for use by the optimizer.
191
<term><option>-Z</option></term>
192
<term><option>--analyze-only</option></term>
195
Only calculate statistics for use by the optimizer (no vacuum).
201
<term><option>-?</></term>
202
<term><option>--help</></term>
205
Show help about <application>vacuumdb</application> command line
215
<application>vacuumdb</application> also accepts
216
the following command-line arguments for connection parameters:
219
<term><option>-h <replaceable class="parameter">host</replaceable></></term>
220
<term><option>--host=<replaceable class="parameter">host</replaceable></></term>
223
Specifies the host name of the machine on which the server
224
is running. If the value begins with a slash, it is used
225
as the directory for the Unix domain socket.
231
<term><option>-p <replaceable class="parameter">port</replaceable></></term>
232
<term><option>--port=<replaceable class="parameter">port</replaceable></></term>
235
Specifies the TCP port or local Unix domain socket file
236
extension on which the server
237
is listening for connections.
243
<term><option>-U <replaceable class="parameter">username</replaceable></></term>
244
<term><option>--username=<replaceable class="parameter">username</replaceable></></term>
247
User name to connect as.
253
<term><option>-w</></term>
254
<term><option>--no-password</></term>
257
Never issue a password prompt. If the server requires
258
password authentication and a password is not available by
259
other means such as a <filename>.pgpass</filename> file, the
260
connection attempt will fail. This option can be useful in
261
batch jobs and scripts where no user is present to enter a
268
<term><option>-W</></term>
269
<term><option>--password</></term>
272
Force <application>vacuumdb</application> to prompt for a
273
password before connecting to a database.
277
This option is never essential, since
278
<application>vacuumdb</application> will automatically prompt
279
for a password if the server demands password authentication.
280
However, <application>vacuumdb</application> will waste a
281
connection attempt finding out that the server wants a password.
282
In some cases it is worth typing <option>-W</> to avoid the extra
293
<title>Environment</title>
297
<term><envar>PGDATABASE</envar></term>
298
<term><envar>PGHOST</envar></term>
299
<term><envar>PGPORT</envar></term>
300
<term><envar>PGUSER</envar></term>
304
Default connection parameters
311
This utility, like most other <productname>PostgreSQL</> utilities,
312
also uses the environment variables supported by <application>libpq</>
313
(see <xref linkend="libpq-envars">).
320
<title>Diagnostics</title>
323
In case of difficulty, see <xref linkend="SQL-VACUUM">
324
and <xref linkend="APP-PSQL"> for
325
discussions of potential problems and error messages.
326
The database server must be running at the
327
targeted host. Also, any default connection settings and environment
328
variables used by the <application>libpq</application> front-end
339
<application>vacuumdb</application> might need to connect several
340
times to the <productname>PostgreSQL</productname> server, asking
341
for a password each time. It is convenient to have a
342
<filename>~/.pgpass</> file in such cases. See <xref
343
linkend="libpq-pgpass"> for more information.
348
<title>Examples</title>
351
To clean the database <literal>test</literal>:
353
<prompt>$ </prompt><userinput>vacuumdb test</userinput>
358
To clean and analyze for the optimizer a database named
359
<literal>bigdb</literal>:
361
<prompt>$ </prompt><userinput>vacuumdb --analyze bigdb</userinput>
366
To clean a single table
367
<literal>foo</literal> in a database named
368
<literal>xyzzy</literal>, and analyze a single column
369
<literal>bar</literal> of the table for the optimizer:
371
<prompt>$ </prompt><userinput>vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy</userinput>
378
<title>See Also</title>
380
<simplelist type="inline">
381
<member><xref linkend="sql-vacuum"></member>