]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/reindexdb.sgml
Trim trailing whitespace
[postgresql] / doc / src / sgml / ref / reindexdb.sgml
1 <!--
2 doc/src/sgml/ref/reindexdb.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="APP-REINDEXDB">
7  <indexterm zone="app-reindexdb">
8   <primary>reindexdb</primary>
9  </indexterm>
10
11  <refmeta>
12   <refentrytitle><application>reindexdb</application></refentrytitle>
13   <manvolnum>1</manvolnum>
14   <refmiscinfo>Application</refmiscinfo>
15  </refmeta>
16
17  <refnamediv>
18   <refname id="reindexdb">reindexdb</refname>
19   <refpurpose>reindex a <productname>PostgreSQL</productname> database</refpurpose>
20  </refnamediv>
21
22  <refsynopsisdiv>
23   <cmdsynopsis>
24    <command>reindexdb</command>
25    <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
26    <arg rep="repeat"><replaceable>option</replaceable></arg>
27
28    <arg choice="plain" rep="repeat">
29     <arg choice="opt">
30      <group choice="plain">
31       <arg choice="plain"><option>--schema</option></arg>
32       <arg choice="plain"><option>-S</option></arg>
33      </group>
34      <replaceable>schema</replaceable>
35     </arg>
36    </arg>
37
38    <arg choice="plain" rep="repeat">
39     <arg choice="opt">
40      <group choice="plain">
41       <arg choice="plain"><option>--table</option></arg>
42       <arg choice="plain"><option>-t</option></arg>
43      </group>
44      <replaceable>table</replaceable>
45     </arg>
46    </arg>
47
48    <arg choice="plain" rep="repeat">
49     <arg choice="opt">
50      <group choice="plain">
51       <arg choice="plain"><option>--index</option></arg>
52       <arg choice="plain"><option>-i</option></arg>
53      </group>
54      <replaceable>index</replaceable>
55     </arg>
56    </arg>
57
58    <arg choice="opt"><replaceable>dbname</replaceable></arg>
59   </cmdsynopsis>
60
61   <cmdsynopsis>
62    <command>reindexdb</command>
63    <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
64    <arg rep="repeat"><replaceable>option</replaceable></arg>
65
66    <group choice="plain">
67     <arg choice="plain"><option>--all</option></arg>
68     <arg choice="plain"><option>-a</option></arg>
69    </group>
70   </cmdsynopsis>
71
72   <cmdsynopsis>
73    <command>reindexdb</command>
74    <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
75    <arg rep="repeat"><replaceable>option</replaceable></arg>
76
77    <group choice="plain">
78     <arg choice="plain"><option>--system</option></arg>
79     <arg choice="plain"><option>-s</option></arg>
80    </group>
81    <arg choice="opt"><replaceable>dbname</replaceable></arg>
82   </cmdsynopsis>
83  </refsynopsisdiv>
84
85
86  <refsect1>
87   <title>Description</title>
88
89   <para>
90    <application>reindexdb</application> is a utility for rebuilding indexes
91    in a <productname>PostgreSQL</productname> database.
92   </para>
93
94   <para>
95    <application>reindexdb</application> is a wrapper around the SQL
96    command <xref linkend="SQL-REINDEX">.
97    There is no effective difference between reindexing databases via
98    this utility and via other methods for accessing the server.
99   </para>
100
101  </refsect1>
102
103
104  <refsect1>
105   <title>Options</title>
106
107    <para>
108     <application>reindexdb</application> accepts the following command-line arguments:
109
110     <variablelist>
111      <varlistentry>
112       <term><option>-a</></term>
113       <term><option>--all</></term>
114       <listitem>
115        <para>
116         Reindex all databases.
117        </para>
118       </listitem>
119      </varlistentry>
120
121      <varlistentry>
122       <term><option><optional>-d</> <replaceable class="parameter">dbname</replaceable></></term>
123       <term><option><optional>--dbname=</><replaceable class="parameter">dbname</replaceable></></term>
124       <listitem>
125        <para>
126         Specifies the name of the database to be reindexed.
127         If this is not specified and <option>-a</option> (or
128         <option>--all</option>) is not used, the database name is read
129         from the environment variable <envar>PGDATABASE</envar>.  If
130         that is not set, the user name specified for the connection is
131         used.
132        </para>
133       </listitem>
134      </varlistentry>
135
136      <varlistentry>
137       <term><option>-e</></term>
138       <term><option>--echo</></term>
139       <listitem>
140        <para>
141         Echo the commands that <application>reindexdb</application> generates
142         and sends to the server.
143        </para>
144       </listitem>
145      </varlistentry>
146
147      <varlistentry>
148       <term><option>-i <replaceable class="parameter">index</replaceable></></term>
149       <term><option>--index=<replaceable class="parameter">index</replaceable></></term>
150       <listitem>
151        <para>
152         Recreate <replaceable class="parameter">index</replaceable> only.
153         Multiple indexes can be recreated by writing multiple
154         <option>-i</> switches.
155        </para>
156       </listitem>
157      </varlistentry>
158
159      <varlistentry>
160       <term><option>-q</></term>
161       <term><option>--quiet</></term>
162       <listitem>
163        <para>
164         Do not display progress messages.
165        </para>
166       </listitem>
167      </varlistentry>
168
169      <varlistentry>
170       <term><option>-s</></term>
171       <term><option>--system</></term>
172       <listitem>
173        <para>
174         Reindex database's system catalogs.
175        </para>
176       </listitem>
177      </varlistentry>
178
179      <varlistentry>
180       <term><option>-S <replaceable class="parameter">schema</replaceable></></term>
181       <term><option>--schema=<replaceable class="parameter">schema</replaceable></></term>
182       <listitem>
183        <para>
184         Reindex <replaceable class="parameter">schema</replaceable> only.
185         Multiple schemas can be reindexed by writing multiple
186         <option>-S</> switches.
187        </para>
188       </listitem>
189      </varlistentry>
190
191      <varlistentry>
192       <term><option>-t <replaceable class="parameter">table</replaceable></></term>
193       <term><option>--table=<replaceable class="parameter">table</replaceable></></term>
194       <listitem>
195        <para>
196         Reindex <replaceable class="parameter">table</replaceable> only.
197         Multiple tables can be reindexed by writing multiple
198         <option>-t</> switches.
199        </para>
200       </listitem>
201      </varlistentry>
202
203     <varlistentry>
204      <term><option>-v</></term>
205      <term><option>--verbose</></term>
206      <listitem>
207       <para>
208        Print detailed information during processing.
209       </para>
210      </listitem>
211     </varlistentry>
212
213     <varlistentry>
214       <term><option>-V</></term>
215       <term><option>--version</></term>
216       <listitem>
217        <para>
218        Print the <application>reindexdb</application> version and exit.
219        </para>
220       </listitem>
221     </varlistentry>
222
223     <varlistentry>
224       <term><option>-?</></term>
225       <term><option>--help</></term>
226       <listitem>
227       <para>
228       Show help about <application>reindexdb</application> command line
229       arguments, and exit.
230       </para>
231       </listitem>
232     </varlistentry>
233
234    </variablelist>
235
236    </para>
237
238    <para>
239     <application>reindexdb</application> also accepts
240     the following command-line arguments for connection parameters:
241
242     <variablelist>
243      <varlistentry>
244       <term><option>-h <replaceable class="parameter">host</replaceable></></term>
245       <term><option>--host=<replaceable class="parameter">host</replaceable></></term>
246       <listitem>
247        <para>
248         Specifies the host name of the machine on which the server is
249         running.  If the value begins with a slash, it is used as the
250         directory for the Unix domain socket.
251        </para>
252       </listitem>
253      </varlistentry>
254
255      <varlistentry>
256       <term><option>-p <replaceable class="parameter">port</replaceable></></term>
257       <term><option>--port=<replaceable class="parameter">port</replaceable></></term>
258       <listitem>
259        <para>
260         Specifies the TCP port or local Unix domain socket file
261         extension on which the server
262         is listening for connections.
263        </para>
264       </listitem>
265      </varlistentry>
266
267      <varlistentry>
268       <term><option>-U <replaceable class="parameter">username</replaceable></></term>
269       <term><option>--username=<replaceable class="parameter">username</replaceable></></term>
270       <listitem>
271        <para>
272         User name to connect as.
273        </para>
274       </listitem>
275      </varlistentry>
276
277      <varlistentry>
278       <term><option>-w</></term>
279       <term><option>--no-password</></term>
280       <listitem>
281        <para>
282         Never issue a password prompt.  If the server requires
283         password authentication and a password is not available by
284         other means such as a <filename>.pgpass</filename> file, the
285         connection attempt will fail.  This option can be useful in
286         batch jobs and scripts where no user is present to enter a
287         password.
288        </para>
289       </listitem>
290      </varlistentry>
291
292      <varlistentry>
293       <term><option>-W</></term>
294       <term><option>--password</></term>
295       <listitem>
296        <para>
297         Force <application>reindexdb</application> to prompt for a
298         password before connecting to a database.
299        </para>
300
301        <para>
302         This option is never essential, since
303         <application>reindexdb</application> will automatically prompt
304         for a password if the server demands password authentication.
305         However, <application>reindexdb</application> will waste a
306         connection attempt finding out that the server wants a password.
307         In some cases it is worth typing <option>-W</> to avoid the extra
308         connection attempt.
309        </para>
310       </listitem>
311      </varlistentry>
312
313      <varlistentry>
314       <term><option>--maintenance-db=<replaceable class="parameter">dbname</replaceable></></term>
315       <listitem>
316        <para>
317          Specifies the name of the database to connect to discover what other
318          databases should be reindexed. If not specified, the
319          <literal>postgres</literal> database will be used,
320          and if that does not exist, <literal>template1</literal> will be used.
321        </para>
322       </listitem>
323      </varlistentry>
324     </variablelist>
325    </para>
326  </refsect1>
327
328
329  <refsect1>
330   <title>Environment</title>
331
332   <variablelist>
333    <varlistentry>
334     <term><envar>PGDATABASE</envar></term>
335     <term><envar>PGHOST</envar></term>
336     <term><envar>PGPORT</envar></term>
337     <term><envar>PGUSER</envar></term>
338
339     <listitem>
340      <para>
341       Default connection parameters
342      </para>
343     </listitem>
344    </varlistentry>
345   </variablelist>
346
347   <para>
348    This utility, like most other <productname>PostgreSQL</> utilities,
349    also uses the environment variables supported by <application>libpq</>
350    (see <xref linkend="libpq-envars">).
351   </para>
352
353  </refsect1>
354
355
356  <refsect1>
357   <title>Diagnostics</title>
358
359   <para>
360    In case of difficulty, see <xref linkend="SQL-REINDEX">
361    and <xref linkend="APP-PSQL"> for
362    discussions of potential problems and error messages.
363    The database server must be running at the
364    targeted host.  Also, any default connection settings and environment
365    variables used by the <application>libpq</application> front-end
366    library will apply.
367   </para>
368
369  </refsect1>
370
371
372  <refsect1>
373   <title>Notes</title>
374
375   <para>
376    <application>reindexdb</application> might need to connect several
377    times to the <productname>PostgreSQL</productname> server, asking
378    for a password each time. It is convenient to have a
379    <filename>~/.pgpass</> file in such cases. See <xref
380    linkend="libpq-pgpass"> for more information.
381   </para>
382  </refsect1>
383
384
385  <refsect1>
386   <title>Examples</title>
387
388    <para>
389     To reindex the database <literal>test</literal>:
390 <screen>
391 <prompt>$ </prompt><userinput>reindexdb test</userinput>
392 </screen>
393    </para>
394
395    <para>
396     To reindex the table <literal>foo</literal> and the index
397     <literal>bar</literal> in a database named <literal>abcd</literal>:
398 <screen>
399 <prompt>$ </prompt><userinput>reindexdb --table=foo --index=bar abcd</userinput>
400 </screen></para>
401
402  </refsect1>
403
404  <refsect1>
405   <title>See Also</title>
406
407   <simplelist type="inline">
408    <member><xref linkend="sql-reindex"></member>
409   </simplelist>
410  </refsect1>
411
412 </refentry>