2 $PostgreSQL: pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.41 2007/06/04 10:02:40 petere Exp $
3 PostgreSQL documentation
6 <refentry id="APP-VACUUMDB">
8 <refentrytitle id="APP-VACUUMDB-TITLE"><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>--verbose</arg><arg>-v</arg></group>
28 <group><arg>--analyze</arg><arg>-z</arg></group>
29 <arg>--table | -t <replaceable>table</replaceable>
30 <arg>( <replaceable class="parameter">column</replaceable> [,...] )</arg>
32 <arg><replaceable>dbname</replaceable></arg>
34 <command>vacuumdb</command>
35 <arg rep="repeat"><replaceable>connection-options</replaceable></arg>
36 <group><arg>--all</arg><arg>-a</arg></group>
37 <group><arg>--full</arg><arg>-f</arg></group>
38 <group><arg>--verbose</arg><arg>-v</arg></group>
39 <group><arg>--analyze</arg><arg>-z</arg></group>
45 <title>Description</title>
48 <application>vacuumdb</application> is a utility for cleaning a
49 <productname>PostgreSQL</productname> database.
50 <application>vacuumdb</application> will also generate internal statistics
51 used by the <productname>PostgreSQL</productname> query optimizer.
55 <application>vacuumdb</application> is a wrapper around the SQL
56 command <xref linkend="SQL-VACUUM" endterm="SQL-VACUUM-title">.
57 There is no effective difference between vacuuming databases via
58 this utility and via other methods for accessing the server.
65 <title>Options</title>
68 <application>vacuumdb</application> accepts the following command-line arguments:
72 <term><option>-a</option></term>
73 <term><option>--all</option></term>
82 <term><option><optional>-d</> <replaceable class="parameter">dbname</replaceable></option></term>
83 <term><option><optional>--dbname</> <replaceable class="parameter">dbname</replaceable></option></term>
86 Specifies the name of the database to be cleaned or analyzed.
87 If this is not specified and <option>-a</option> (or
88 <option>--all</option>) is not used, the database name is read
89 from the environment variable <envar>PGDATABASE</envar>. If
90 that is not set, the user name specified for the connection is
97 <term><option>-e</></term>
98 <term><option>--echo</></term>
101 Echo the commands that <application>vacuumdb</application> generates
102 and sends to the server.
108 <term><option>-f</option></term>
109 <term><option>--full</option></term>
112 Perform <quote>full</quote> vacuuming.
118 <term><option>-q</></term>
119 <term><option>--quiet</></term>
122 Do not display progress messages.
128 <term><option>-t <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</option></term>
129 <term><option>--table <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</option></term>
132 Clean or analyze <replaceable class="parameter">table</replaceable> only.
133 Column names can be specified only in conjunction with
134 the <option>--analyze</option> option.
138 If you specify columns, you probably have to escape the parentheses
139 from the shell. (See examples below.)
146 <term><option>-v</option></term>
147 <term><option>--verbose</option></term>
150 Print detailed information during processing.
156 <term><option>-z</option></term>
157 <term><option>--analyze</option></term>
160 Calculate statistics for use by the optimizer.
168 <application>vacuumdb</application> also accepts
169 the following command-line arguments for connection parameters:
173 <term><option>-h <replaceable class="parameter">host</replaceable></></term>
174 <term><option>--host <replaceable class="parameter">host</replaceable></></term>
177 Specifies the host name of the machine on which the
179 is running. If the value begins with a slash, it is used
180 as the directory for the Unix domain socket.
186 <term><option>-p <replaceable class="parameter">port</replaceable></></term>
187 <term><option>--port <replaceable class="parameter">port</replaceable></></term>
190 Specifies the TCP port or local Unix domain socket file
191 extension on which the server
192 is listening for connections.
198 <term><option>-U <replaceable class="parameter">username</replaceable></></term>
199 <term><option>--username <replaceable class="parameter">username</replaceable></></term>
202 User name to connect as
208 <term><option>-W</></term>
209 <term><option>--password</></term>
212 Force password prompt.
222 <title>Environment</title>
226 <term><envar>PGDATABASE</envar></term>
227 <term><envar>PGHOST</envar></term>
228 <term><envar>PGPORT</envar></term>
229 <term><envar>PGUSER</envar></term>
233 Default connection parameters
240 This utility, like most other <productname>PostgreSQL</> utilities,
241 also uses the environment variables supported by <application>libpq</>
242 (see <xref linkend="libpq-envars">).
249 <title>Diagnostics</title>
252 In case of difficulty, see <xref linkend="SQL-VACUUM"
253 endterm="sql-vacuum-title"> and <xref linkend="APP-PSQL"> for
254 discussions of potential problems and error messages.
255 The database server must be running at the
256 targeted host. Also, any default connection settings and environment
257 variables used by the <application>libpq</application> front-end
268 <application>vacuumdb</application> might need to connect several
269 times to the <productname>PostgreSQL</productname> server, asking
270 for a password each time. It is convenient to have a
271 <filename>~/.pgpass</> file in such cases. See <xref
272 linkend="libpq-pgpass"> for more information.
277 <title>Examples</title>
280 To clean the database <literal>test</literal>:
282 <prompt>$ </prompt><userinput>vacuumdb test</userinput>
287 To clean and analyze for the optimizer a database named
288 <literal>bigdb</literal>:
290 <prompt>$ </prompt><userinput>vacuumdb --analyze bigdb</userinput>
295 To clean a single table
296 <literal>foo</literal> in a database named
297 <literal>xyzzy</literal>, and analyze a single column
298 <literal>bar</literal> of the table for the optimizer:
300 <prompt>$ </prompt><userinput>vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy</userinput>
307 <title>See Also</title>
309 <simplelist type="inline">
310 <member><xref linkend="sql-vacuum" endterm="sql-vacuum-title"></member>