~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/ref/vacuumdb.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--
 
2
doc/src/sgml/ref/vacuumdb.sgml
 
3
PostgreSQL documentation
 
4
-->
 
5
 
 
6
<refentry id="APP-VACUUMDB">
 
7
 <refmeta>
 
8
  <refentrytitle><application>vacuumdb</application></refentrytitle>
 
9
  <manvolnum>1</manvolnum>
 
10
  <refmiscinfo>Application</refmiscinfo>
 
11
 </refmeta>
 
12
 
 
13
 <refnamediv>
 
14
  <refname id="vacuumdb">vacuumdb</refname>
 
15
  <refpurpose>garbage-collect and analyze a <productname>PostgreSQL</productname> database</refpurpose>
 
16
 </refnamediv>
 
17
 
 
18
 <indexterm zone="app-vacuumdb">
 
19
  <primary>vacuumdb</primary>
 
20
 </indexterm>
 
21
 
 
22
 <refsynopsisdiv>
 
23
  <cmdsynopsis>
 
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>
 
33
   </arg>
 
34
   <arg><replaceable>dbname</replaceable></arg>
 
35
  </cmdsynopsis>
 
36
 
 
37
  <cmdsynopsis>
 
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>
 
46
  </cmdsynopsis>
 
47
 </refsynopsisdiv>
 
48
 
 
49
 <refsect1>
 
50
  <title>Description</title>
 
51
 
 
52
  <para>
 
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.
 
57
  </para>
 
58
 
 
59
  <para>
 
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
 
64
   server.
 
65
  </para>
 
66
 
 
67
 </refsect1>
 
68
 
 
69
 
 
70
 <refsect1>
 
71
  <title>Options</title>
 
72
 
 
73
   <para>
 
74
    <application>vacuumdb</application> accepts the following command-line arguments:
 
75
    <variablelist>
 
76
     <varlistentry>
 
77
      <term><option>-a</option></term>
 
78
      <term><option>--all</option></term>
 
79
      <listitem>
 
80
       <para>
 
81
        Vacuum all databases.
 
82
       </para>
 
83
      </listitem>
 
84
     </varlistentry>
 
85
 
 
86
     <varlistentry>
 
87
      <term><option><optional>-d</> <replaceable class="parameter">dbname</replaceable></option></term>
 
88
      <term><option><optional>--dbname=</><replaceable class="parameter">dbname</replaceable></option></term>
 
89
      <listitem>
 
90
       <para>
 
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
 
96
        used.
 
97
       </para>
 
98
      </listitem>
 
99
     </varlistentry>
 
100
 
 
101
     <varlistentry>
 
102
      <term><option>-e</></term>
 
103
      <term><option>--echo</></term>
 
104
      <listitem>
 
105
       <para>
 
106
        Echo the commands that <application>vacuumdb</application> generates
 
107
        and sends to the server.
 
108
       </para>
 
109
      </listitem>
 
110
     </varlistentry>
 
111
 
 
112
     <varlistentry>
 
113
      <term><option>-f</option></term>
 
114
      <term><option>--full</option></term>
 
115
      <listitem>
 
116
       <para>
 
117
        Perform <quote>full</quote> vacuuming.
 
118
       </para>
 
119
      </listitem>
 
120
     </varlistentry>
 
121
 
 
122
     <varlistentry>
 
123
      <term><option>-F</option></term>
 
124
      <term><option>--freeze</option></term>
 
125
      <listitem>
 
126
       <para>
 
127
        Aggressively <quote>freeze</quote> tuples.
 
128
       </para>
 
129
      </listitem>
 
130
     </varlistentry>
 
131
 
 
132
     <varlistentry>
 
133
      <term><option>-q</></term>
 
134
      <term><option>--quiet</></term>
 
135
      <listitem>
 
136
       <para>
 
137
        Do not display progress messages.
 
138
       </para>
 
139
      </listitem>
 
140
     </varlistentry>
 
141
 
 
142
     <varlistentry>
 
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>
 
145
      <listitem>
 
146
       <para>
 
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.
 
150
       </para>
 
151
       <tip>
 
152
        <para>
 
153
         If you specify columns, you probably have to escape the parentheses
 
154
         from the shell.  (See examples below.)
 
155
        </para>
 
156
       </tip>
 
157
      </listitem>
 
158
     </varlistentry>
 
159
 
 
160
     <varlistentry>
 
161
      <term><option>-v</option></term>
 
162
      <term><option>--verbose</option></term>
 
163
      <listitem>
 
164
       <para>
 
165
        Print detailed information during processing.
 
166
       </para>
 
167
      </listitem>
 
168
     </varlistentry>
 
169
 
 
170
     <varlistentry>
 
171
       <term><option>-V</></term>
 
172
       <term><option>--version</></term>
 
173
       <listitem>
 
174
       <para>
 
175
       Print the <application>vacuumdb</application> version and exit.
 
176
       </para>
 
177
       </listitem>
 
178
     </varlistentry>
 
179
 
 
180
     <varlistentry>
 
181
      <term><option>-z</option></term>
 
182
      <term><option>--analyze</option></term>
 
183
      <listitem>
 
184
       <para>
 
185
        Also calculate statistics for use by the optimizer.
 
186
       </para>
 
187
      </listitem>
 
188
     </varlistentry>
 
189
 
 
190
     <varlistentry>
 
191
      <term><option>-Z</option></term>
 
192
      <term><option>--analyze-only</option></term>
 
193
      <listitem>
 
194
       <para>
 
195
        Only calculate statistics for use by the optimizer (no vacuum).
 
196
       </para>
 
197
      </listitem>
 
198
     </varlistentry>
 
199
 
 
200
     <varlistentry>
 
201
       <term><option>-?</></term>
 
202
       <term><option>--help</></term>
 
203
       <listitem>
 
204
       <para>
 
205
       Show help about <application>vacuumdb</application> command line
 
206
       arguments, and exit.
 
207
       </para>
 
208
       </listitem>
 
209
     </varlistentry>
 
210
 
 
211
    </variablelist>
 
212
   </para>
 
213
 
 
214
   <para>
 
215
    <application>vacuumdb</application> also accepts
 
216
    the following command-line arguments for connection parameters:
 
217
    <variablelist>
 
218
     <varlistentry>
 
219
      <term><option>-h <replaceable class="parameter">host</replaceable></></term>
 
220
      <term><option>--host=<replaceable class="parameter">host</replaceable></></term>
 
221
      <listitem>
 
222
       <para>
 
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.
 
226
       </para>
 
227
      </listitem>
 
228
     </varlistentry>
 
229
 
 
230
     <varlistentry>
 
231
      <term><option>-p <replaceable class="parameter">port</replaceable></></term>
 
232
      <term><option>--port=<replaceable class="parameter">port</replaceable></></term>
 
233
      <listitem>
 
234
       <para>
 
235
        Specifies the TCP port or local Unix domain socket file
 
236
        extension on which the server
 
237
        is listening for connections.
 
238
       </para>
 
239
      </listitem>
 
240
     </varlistentry>
 
241
 
 
242
     <varlistentry>
 
243
      <term><option>-U <replaceable class="parameter">username</replaceable></></term>
 
244
      <term><option>--username=<replaceable class="parameter">username</replaceable></></term>
 
245
      <listitem>
 
246
       <para>
 
247
        User name to connect as.
 
248
       </para>
 
249
      </listitem>
 
250
     </varlistentry>
 
251
 
 
252
     <varlistentry>
 
253
      <term><option>-w</></term>
 
254
      <term><option>--no-password</></term>
 
255
      <listitem>
 
256
       <para>
 
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
 
262
        password.
 
263
       </para>
 
264
      </listitem>
 
265
     </varlistentry>
 
266
 
 
267
     <varlistentry>
 
268
      <term><option>-W</></term>
 
269
      <term><option>--password</></term>
 
270
      <listitem>
 
271
       <para>
 
272
        Force <application>vacuumdb</application> to prompt for a
 
273
        password before connecting to a database.
 
274
       </para>
 
275
 
 
276
       <para>
 
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
 
283
        connection attempt.
 
284
       </para>
 
285
      </listitem>
 
286
     </varlistentry>
 
287
    </variablelist>
 
288
   </para>
 
289
 </refsect1>
 
290
 
 
291
 
 
292
 <refsect1>
 
293
  <title>Environment</title>
 
294
 
 
295
  <variablelist>
 
296
   <varlistentry>
 
297
    <term><envar>PGDATABASE</envar></term>
 
298
    <term><envar>PGHOST</envar></term>
 
299
    <term><envar>PGPORT</envar></term>
 
300
    <term><envar>PGUSER</envar></term>
 
301
 
 
302
    <listitem>
 
303
     <para>
 
304
      Default connection parameters
 
305
     </para>
 
306
    </listitem>
 
307
   </varlistentry>
 
308
  </variablelist>
 
309
 
 
310
  <para>
 
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">).
 
314
  </para>
 
315
 
 
316
 </refsect1>
 
317
 
 
318
 
 
319
 <refsect1>
 
320
  <title>Diagnostics</title>
 
321
 
 
322
  <para>
 
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
 
329
   library will apply.
 
330
  </para>
 
331
 
 
332
 </refsect1>
 
333
 
 
334
 
 
335
 <refsect1>
 
336
  <title>Notes</title>
 
337
 
 
338
  <para>
 
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.
 
344
  </para>
 
345
 </refsect1>
 
346
 
 
347
 <refsect1>
 
348
  <title>Examples</title>
 
349
 
 
350
   <para>
 
351
    To clean the database <literal>test</literal>:
 
352
<screen>
 
353
<prompt>$ </prompt><userinput>vacuumdb test</userinput>
 
354
</screen>
 
355
   </para>
 
356
 
 
357
   <para>
 
358
    To clean and analyze for the optimizer a database named
 
359
    <literal>bigdb</literal>:
 
360
<screen>
 
361
<prompt>$ </prompt><userinput>vacuumdb --analyze bigdb</userinput>
 
362
</screen>
 
363
   </para>
 
364
 
 
365
   <para>
 
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:
 
370
<screen>
 
371
<prompt>$ </prompt><userinput>vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy</userinput>
 
372
</screen>
 
373
   </para>
 
374
 
 
375
 </refsect1>
 
376
 
 
377
 <refsect1>
 
378
  <title>See Also</title>
 
379
 
 
380
  <simplelist type="inline">
 
381
   <member><xref linkend="sql-vacuum"></member>
 
382
  </simplelist>
 
383
 </refsect1>
 
384
 
 
385
</refentry>