2 doc/src/sgml/ref/reindexdb.sgml
3 PostgreSQL documentation
6 <refentry id=
"app-reindexdb">
7 <indexterm zone=
"app-reindexdb">
8 <primary>reindexdb
</primary>
12 <refentrytitle><application>reindexdb
</application></refentrytitle>
13 <manvolnum>1</manvolnum>
14 <refmiscinfo>Application
</refmiscinfo>
18 <refname>reindexdb
</refname>
19 <refpurpose>reindex a
<productname>PostgreSQL
</productname> database
</refpurpose>
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">
30 <group choice=
"plain">
31 <arg choice=
"plain"><option>-S
</option></arg>
32 <arg choice=
"plain"><option>--schema
</option></arg>
34 <replaceable>schema
</replaceable>
38 <arg choice=
"plain" rep=
"repeat">
40 <group choice=
"plain">
41 <arg choice=
"plain"><option>-t
</option></arg>
42 <arg choice=
"plain"><option>--table
</option></arg>
44 <replaceable>table
</replaceable>
48 <arg choice=
"plain" rep=
"repeat">
50 <group choice=
"plain">
51 <arg choice=
"plain"><option>-i
</option></arg>
52 <arg choice=
"plain"><option>--index
</option></arg>
54 <replaceable>index
</replaceable>
58 <arg choice=
"opt"><replaceable>dbname
</replaceable></arg>
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>
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>
81 <arg choice=
"opt"><replaceable>dbname
</replaceable></arg>
87 <title>Description
</title>
90 <application>reindexdb
</application> is a utility for rebuilding indexes
91 in a
<productname>PostgreSQL
</productname> database.
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.
105 <title>Options
</title>
108 <application>reindexdb
</application> accepts the following command-line arguments:
112 <term><option>-a
</option></term>
113 <term><option>--all
</option></term>
116 Reindex all databases.
122 <term><option>--concurrently
</option></term>
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.
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>
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
151 <term><option>-e
</option></term>
152 <term><option>--echo
</option></term>
155 Echo the commands that
<application>reindexdb
</application> generates
156 and sends to the server.
162 <term><option>-i
<replaceable class=
"parameter">index
</replaceable></option></term>
163 <term><option>--index=
<replaceable class=
"parameter">index
</replaceable></option></term>
166 Recreate
<replaceable class=
"parameter">index
</replaceable> only.
167 Multiple indexes can be recreated by writing multiple
168 <option>-i
</option> switches.
174 <term><option>-j
<replaceable class=
"parameter">njobs
</replaceable></option></term>
175 <term><option>--jobs=
<replaceable class=
"parameter">njobs
</replaceable></option></term>
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.
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.
190 Note that this option is incompatible with the
<option>--index
</option>
191 and
<option>--system
</option> options.
197 <term><option>-q
</option></term>
198 <term><option>--quiet
</option></term>
201 Do not display progress messages.
207 <term><option>-s
</option></term>
208 <term><option>--system
</option></term>
211 Reindex database's system catalogs only.
217 <term><option>-S
<replaceable class=
"parameter">schema
</replaceable></option></term>
218 <term><option>--schema=
<replaceable class=
"parameter">schema
</replaceable></option></term>
221 Reindex
<replaceable class=
"parameter">schema
</replaceable> only.
222 Multiple schemas can be reindexed by writing multiple
223 <option>-S
</option> switches.
229 <term><option>-t
<replaceable class=
"parameter">table
</replaceable></option></term>
230 <term><option>--table=
<replaceable class=
"parameter">table
</replaceable></option></term>
233 Reindex
<replaceable class=
"parameter">table
</replaceable> only.
234 Multiple tables can be reindexed by writing multiple
235 <option>-t
</option> switches.
241 <term><option>--tablespace=
<replaceable class=
"parameter">tablespace
</replaceable></option></term>
244 Specifies the tablespace where indexes are rebuilt. (This name is
245 processed as a double-quoted identifier.)
251 <term><option>-v
</option></term>
252 <term><option>--verbose
</option></term>
255 Print detailed information during processing.
261 <term><option>-V
</option></term>
262 <term><option>--version
</option></term>
265 Print the
<application>reindexdb
</application> version and exit.
271 <term><option>-?
</option></term>
272 <term><option>--help
</option></term>
275 Show help about
<application>reindexdb
</application> command line
286 <application>reindexdb
</application> also accepts
287 the following command-line arguments for connection parameters:
291 <term><option>-h
<replaceable class=
"parameter">host
</replaceable></option></term>
292 <term><option>--host=
<replaceable class=
"parameter">host
</replaceable></option></term>
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.
303 <term><option>-p
<replaceable class=
"parameter">port
</replaceable></option></term>
304 <term><option>--port=
<replaceable class=
"parameter">port
</replaceable></option></term>
307 Specifies the TCP port or local Unix domain socket file
308 extension on which the server
309 is listening for connections.
315 <term><option>-U
<replaceable class=
"parameter">username
</replaceable></option></term>
316 <term><option>--username=
<replaceable class=
"parameter">username
</replaceable></option></term>
319 User name to connect as.
325 <term><option>-w
</option></term>
326 <term><option>--no-password
</option></term>
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
340 <term><option>-W
</option></term>
341 <term><option>--password
</option></term>
344 Force
<application>reindexdb
</application> to prompt for a
345 password before connecting to a database.
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
361 <term><option>--maintenance-db=
<replaceable class=
"parameter">dbname
</replaceable></option></term>
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
383 <title>Environment
</title>
387 <term><envar>PGDATABASE
</envar></term>
388 <term><envar>PGHOST
</envar></term>
389 <term><envar>PGPORT
</envar></term>
390 <term><envar>PGUSER
</envar></term>
394 Default connection parameters
400 <term><envar>PG_COLOR
</envar></term>
403 Specifies whether to use color in diagnostic messages. Possible values
404 are
<literal>always
</literal>,
<literal>auto
</literal> and
405 <literal>never
</literal>.
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"/>).
421 <title>Diagnostics
</title>
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
436 <title>Examples
</title>
439 To reindex the database
<literal>test
</literal>:
441 <prompt>$
</prompt><userinput>reindexdb test
</userinput>
446 To reindex the table
<literal>foo
</literal> and the index
447 <literal>bar
</literal> in a database named
<literal>abcd
</literal>:
449 <prompt>$
</prompt><userinput>reindexdb --table=foo --index=bar abcd
</userinput>
455 <title>See Also
</title>
457 <simplelist type=
"inline">
458 <member><xref linkend=
"sql-reindex"/></member>