For temporary tables, <command>REINDEX</command> is always
non-concurrent, as no other session can access them, and
non-concurrent reindex is cheaper.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>TABLESPACE</literal></term>
<listitem>
<para>
Specifies that indexes will be rebuilt on a new tablespace.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>VERBOSE</literal></term>
<listitem>
<para>
Prints a progress report as each index is reindexed
at <literal>INFO</literal> level.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">boolean</replaceable></term>
<listitem>
<para>
Specifies whether the selected option should be turned on or off.
You can write <literal>TRUE</literal>, <literal>ON</literal>, or
<literal>1</literal> to enable the option, and <literal>FALSE</literal>,
<literal>OFF</literal>, or <literal>0</literal> to disable it. The
<replaceable class="parameter">boolean</replaceable> value can also
be omitted, in which case <literal>TRUE</literal> is assumed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">new_tablespace</replaceable></term>
<listitem>
<para>
The tablespace where indexes will be rebuilt.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
If you suspect corruption of an index on a user table, you can
simply rebuild that index, or all indexes on the table, using
<command>REINDEX INDEX</command> or <command>REINDEX TABLE</command>.
</para>
<para>
Things are more difficult if you need to recover from corruption of
an index on a system table. In this case it's important for the
system to not have used any of the suspect indexes itself.
(Indeed, in this sort of scenario you might find that server
processes are crashing immediately at start-up, due to reliance on
the corrupted indexes.) To recover safely, the server must be started
with the <option>-P</option> option, which prevents it from using
indexes for system catalog lookups.
</para>
<para>
One way to do this is to shut down the server and start a single-user
<productname>PostgreSQL</productname> server
with the <option>-P</option> option included on its command line.
Then, <command>REINDEX DATABASE</command>, <command>REINDEX SYSTEM</command>,
<command>REINDEX TABLE</command>, or <command>REINDEX INDEX</command> can be
issued, depending on how much you want to reconstruct. If in
doubt, use <command>REINDEX SYSTEM</command> to select
reconstruction of all system indexes in the database. Then quit
the single-user server session and restart the regular server.
See the <xref linkend="app-postgres"/> reference page for more
information about how to interact with the single-user server
interface.
</para>
<para>
Alternatively, a regular server session can be started with
<option>-P</option> included in its command line options.
The method for doing this varies across clients, but in all
<application>libpq</application>-based clients, it is possible to set
the <envar>PGOPTIONS</envar> environment variable to <literal>-P</literal>
before starting the client. Note that while this method does not
require locking out other clients, it might still be wise to prevent
other users from connecting to the damaged database until repairs
have been completed.
</para>
<para>
<command>REINDEX</command> is similar to a drop and recreate of the index
in that the index contents are rebuilt from scratch. However, the locking
considerations are rather different. <command>REINDEX</command> locks out writes
but not reads of the index's parent table. It also takes an
<literal>ACCESS