doc: ALTER DEFAULT PRIVILEGES does not affect inherited roles
[pgsql.git] / doc / src / sgml / ref / reindexdb.sgml
blob8d9ced212f34f8a87820aa59beb6a324ebe95518
1 <!--
2 doc/src/sgml/ref/reindexdb.sgml
3 PostgreSQL documentation
4 -->
6 <refentry id="app-reindexdb">
7 <indexterm zone="app-reindexdb">
8 <primary>reindexdb</primary>
9 </indexterm>
11 <refmeta>
12 <refentrytitle><application>reindexdb</application></refentrytitle>
13 <manvolnum>1</manvolnum>
14 <refmiscinfo>Application</refmiscinfo>
15 </refmeta>
17 <refnamediv>
18 <refname>reindexdb</refname>
19 <refpurpose>reindex a <productname>PostgreSQL</productname> database</refpurpose>
20 </refnamediv>
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>
28 <arg choice="plain" rep="repeat">
29 <arg choice="opt">
30 <group choice="plain">
31 <arg choice="plain"><option>-S</option></arg>
32 <arg choice="plain"><option>--schema</option></arg>
33 </group>
34 <replaceable>schema</replaceable>
35 </arg>
36 </arg>
38 <arg choice="plain" rep="repeat">
39 <arg choice="opt">
40 <group choice="plain">
41 <arg choice="plain"><option>-t</option></arg>
42 <arg choice="plain"><option>--table</option></arg>
43 </group>
44 <replaceable>table</replaceable>
45 </arg>
46 </arg>
48 <arg choice="plain" rep="repeat">
49 <arg choice="opt">
50 <group choice="plain">
51 <arg choice="plain"><option>-i</option></arg>
52 <arg choice="plain"><option>--index</option></arg>
53 </group>
54 <replaceable>index</replaceable>
55 </arg>
56 </arg>
58 <arg choice="opt"><replaceable>dbname</replaceable></arg>
59 </cmdsynopsis>
61 <cmdsynopsis>
62 <command>reindexdb</command>
63 <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
64 <arg rep="repeat"><replaceable>option</replaceable></arg>
66 <group choice="plain">
67 <arg choice="plain"><option>-a</option></arg>
68 <arg choice="plain"><option>--all</option></arg>
69 </group>
70 </cmdsynopsis>
72 <cmdsynopsis>
73 <command>reindexdb</command>
74 <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
75 <arg rep="repeat"><replaceable>option</replaceable></arg>
77 <group choice="plain">
78 <arg choice="plain"><option>-s</option></arg>
79 <arg choice="plain"><option>--system</option></arg>
80 </group>
81 <arg choice="opt"><replaceable>dbname</replaceable></arg>
82 </cmdsynopsis>
83 </refsynopsisdiv>
86 <refsect1>
87 <title>Description</title>
89 <para>
90 <application>reindexdb</application> is a utility for rebuilding indexes
91 in a <productname>PostgreSQL</productname> database.
92 </para>
94 <para>
95 <application>reindexdb</application> is a wrapper around the SQL
96 command <link linkend="sql-reindex"><command>REINDEX</command></link>.
97 There is no effective difference between reindexing databases via
98 this utility and via other methods for accessing the server.
99 </para>
101 </refsect1>
104 <refsect1>
105 <title>Options</title>
107 <para>
108 <application>reindexdb</application> accepts the following command-line arguments:
110 <variablelist>
111 <varlistentry>
112 <term><option>-a</option></term>
113 <term><option>--all</option></term>
114 <listitem>
115 <para>
116 Reindex all databases.
117 </para>
118 </listitem>
119 </varlistentry>
121 <varlistentry>
122 <term><option>--concurrently</option></term>
123 <listitem>
124 <para>
125 Use the <literal>CONCURRENTLY</literal> option. See
126 <xref linkend="sql-reindex"/>, where all the caveats of this option
127 are explained in detail.
128 </para>
129 </listitem>
130 </varlistentry>
132 <varlistentry>
133 <term><option><optional>-d</optional> <replaceable class="parameter">dbname</replaceable></option></term>
134 <term><option><optional>--dbname=</optional><replaceable class="parameter">dbname</replaceable></option></term>
135 <listitem>
136 <para>
137 Specifies the name of the database to be reindexed,
138 when <option>-a</option>/<option>--all</option> is not used.
139 If this is not specified, the database name is read
140 from the environment variable <envar>PGDATABASE</envar>. If
141 that is not set, the user name specified for the connection is
142 used. The <replaceable>dbname</replaceable> can be a <link
143 linkend="libpq-connstring">connection string</link>. If so,
144 connection string parameters will override any conflicting command
145 line options.
146 </para>
147 </listitem>
148 </varlistentry>
150 <varlistentry>
151 <term><option>-e</option></term>
152 <term><option>--echo</option></term>
153 <listitem>
154 <para>
155 Echo the commands that <application>reindexdb</application> generates
156 and sends to the server.
157 </para>
158 </listitem>
159 </varlistentry>
161 <varlistentry>
162 <term><option>-i <replaceable class="parameter">index</replaceable></option></term>
163 <term><option>--index=<replaceable class="parameter">index</replaceable></option></term>
164 <listitem>
165 <para>
166 Recreate <replaceable class="parameter">index</replaceable> only.
167 Multiple indexes can be recreated by writing multiple
168 <option>-i</option> switches.
169 </para>
170 </listitem>
171 </varlistentry>
173 <varlistentry>
174 <term><option>-j <replaceable class="parameter">njobs</replaceable></option></term>
175 <term><option>--jobs=<replaceable class="parameter">njobs</replaceable></option></term>
176 <listitem>
177 <para>
178 Execute the reindex commands in parallel by running
179 <replaceable class="parameter">njobs</replaceable>
180 commands simultaneously. This option may reduce the processing time
181 but it also increases the load on the database server.
182 </para>
183 <para>
184 <application>reindexdb</application> will open
185 <replaceable class="parameter">njobs</replaceable> connections to the
186 database, so make sure your <xref linkend="guc-max-connections"/>
187 setting is high enough to accommodate all connections.
188 </para>
189 <para>
190 Note that this option is incompatible with the <option>--index</option>
191 and <option>--system</option> options.
192 </para>
193 </listitem>
194 </varlistentry>
196 <varlistentry>
197 <term><option>-q</option></term>
198 <term><option>--quiet</option></term>
199 <listitem>
200 <para>
201 Do not display progress messages.
202 </para>
203 </listitem>
204 </varlistentry>
206 <varlistentry>
207 <term><option>-s</option></term>
208 <term><option>--system</option></term>
209 <listitem>
210 <para>
211 Reindex database's system catalogs only.
212 </para>
213 </listitem>
214 </varlistentry>
216 <varlistentry>
217 <term><option>-S <replaceable class="parameter">schema</replaceable></option></term>
218 <term><option>--schema=<replaceable class="parameter">schema</replaceable></option></term>
219 <listitem>
220 <para>
221 Reindex <replaceable class="parameter">schema</replaceable> only.
222 Multiple schemas can be reindexed by writing multiple
223 <option>-S</option> switches.
224 </para>
225 </listitem>
226 </varlistentry>
228 <varlistentry>
229 <term><option>-t <replaceable class="parameter">table</replaceable></option></term>
230 <term><option>--table=<replaceable class="parameter">table</replaceable></option></term>
231 <listitem>
232 <para>
233 Reindex <replaceable class="parameter">table</replaceable> only.
234 Multiple tables can be reindexed by writing multiple
235 <option>-t</option> switches.
236 </para>
237 </listitem>
238 </varlistentry>
240 <varlistentry>
241 <term><option>--tablespace=<replaceable class="parameter">tablespace</replaceable></option></term>
242 <listitem>
243 <para>
244 Specifies the tablespace where indexes are rebuilt. (This name is
245 processed as a double-quoted identifier.)
246 </para>
247 </listitem>
248 </varlistentry>
250 <varlistentry>
251 <term><option>-v</option></term>
252 <term><option>--verbose</option></term>
253 <listitem>
254 <para>
255 Print detailed information during processing.
256 </para>
257 </listitem>
258 </varlistentry>
260 <varlistentry>
261 <term><option>-V</option></term>
262 <term><option>--version</option></term>
263 <listitem>
264 <para>
265 Print the <application>reindexdb</application> version and exit.
266 </para>
267 </listitem>
268 </varlistentry>
270 <varlistentry>
271 <term><option>-?</option></term>
272 <term><option>--help</option></term>
273 <listitem>
274 <para>
275 Show help about <application>reindexdb</application> command line
276 arguments, and exit.
277 </para>
278 </listitem>
279 </varlistentry>
281 </variablelist>
283 </para>
285 <para>
286 <application>reindexdb</application> also accepts
287 the following command-line arguments for connection parameters:
289 <variablelist>
290 <varlistentry>
291 <term><option>-h <replaceable class="parameter">host</replaceable></option></term>
292 <term><option>--host=<replaceable class="parameter">host</replaceable></option></term>
293 <listitem>
294 <para>
295 Specifies the host name of the machine on which the server is
296 running. If the value begins with a slash, it is used as the
297 directory for the Unix domain socket.
298 </para>
299 </listitem>
300 </varlistentry>
302 <varlistentry>
303 <term><option>-p <replaceable class="parameter">port</replaceable></option></term>
304 <term><option>--port=<replaceable class="parameter">port</replaceable></option></term>
305 <listitem>
306 <para>
307 Specifies the TCP port or local Unix domain socket file
308 extension on which the server
309 is listening for connections.
310 </para>
311 </listitem>
312 </varlistentry>
314 <varlistentry>
315 <term><option>-U <replaceable class="parameter">username</replaceable></option></term>
316 <term><option>--username=<replaceable class="parameter">username</replaceable></option></term>
317 <listitem>
318 <para>
319 User name to connect as.
320 </para>
321 </listitem>
322 </varlistentry>
324 <varlistentry>
325 <term><option>-w</option></term>
326 <term><option>--no-password</option></term>
327 <listitem>
328 <para>
329 Never issue a password prompt. If the server requires
330 password authentication and a password is not available by
331 other means such as a <filename>.pgpass</filename> file, the
332 connection attempt will fail. This option can be useful in
333 batch jobs and scripts where no user is present to enter a
334 password.
335 </para>
336 </listitem>
337 </varlistentry>
339 <varlistentry>
340 <term><option>-W</option></term>
341 <term><option>--password</option></term>
342 <listitem>
343 <para>
344 Force <application>reindexdb</application> to prompt for a
345 password before connecting to a database.
346 </para>
348 <para>
349 This option is never essential, since
350 <application>reindexdb</application> will automatically prompt
351 for a password if the server demands password authentication.
352 However, <application>reindexdb</application> will waste a
353 connection attempt finding out that the server wants a password.
354 In some cases it is worth typing <option>-W</option> to avoid the extra
355 connection attempt.
356 </para>
357 </listitem>
358 </varlistentry>
360 <varlistentry>
361 <term><option>--maintenance-db=<replaceable class="parameter">dbname</replaceable></option></term>
362 <listitem>
363 <para>
364 Specifies the name of the database to connect to to discover which
365 databases should be reindexed,
366 when <option>-a</option>/<option>--all</option> is used.
367 If not specified, the <literal>postgres</literal> database will be used,
368 or if that does not exist, <literal>template1</literal> will be used.
369 This can be a <link linkend="libpq-connstring">connection
370 string</link>. If so, connection string parameters will override any
371 conflicting command line options. Also, connection string parameters
372 other than the database name itself will be re-used when connecting
373 to other databases.
374 </para>
375 </listitem>
376 </varlistentry>
377 </variablelist>
378 </para>
379 </refsect1>
382 <refsect1>
383 <title>Environment</title>
385 <variablelist>
386 <varlistentry>
387 <term><envar>PGDATABASE</envar></term>
388 <term><envar>PGHOST</envar></term>
389 <term><envar>PGPORT</envar></term>
390 <term><envar>PGUSER</envar></term>
392 <listitem>
393 <para>
394 Default connection parameters
395 </para>
396 </listitem>
397 </varlistentry>
399 <varlistentry>
400 <term><envar>PG_COLOR</envar></term>
401 <listitem>
402 <para>
403 Specifies whether to use color in diagnostic messages. Possible values
404 are <literal>always</literal>, <literal>auto</literal> and
405 <literal>never</literal>.
406 </para>
407 </listitem>
408 </varlistentry>
409 </variablelist>
411 <para>
412 This utility, like most other <productname>PostgreSQL</productname> utilities,
413 also uses the environment variables supported by <application>libpq</application>
414 (see <xref linkend="libpq-envars"/>).
415 </para>
417 </refsect1>
420 <refsect1>
421 <title>Diagnostics</title>
423 <para>
424 In case of difficulty, see <xref linkend="sql-reindex"/>
425 and <xref linkend="app-psql"/> for
426 discussions of potential problems and error messages.
427 The database server must be running at the
428 targeted host. Also, any default connection settings and environment
429 variables used by the <application>libpq</application> front-end
430 library will apply.
431 </para>
433 </refsect1>
435 <refsect1>
436 <title>Examples</title>
438 <para>
439 To reindex the database <literal>test</literal>:
440 <screen>
441 <prompt>$ </prompt><userinput>reindexdb test</userinput>
442 </screen>
443 </para>
445 <para>
446 To reindex the table <literal>foo</literal> and the index
447 <literal>bar</literal> in a database named <literal>abcd</literal>:
448 <screen>
449 <prompt>$ </prompt><userinput>reindexdb --table=foo --index=bar abcd</userinput>
450 </screen></para>
452 </refsect1>
454 <refsect1>
455 <title>See Also</title>
457 <simplelist type="inline">
458 <member><xref linkend="sql-reindex"/></member>
459 </simplelist>
460 </refsect1>
462 </refentry>