REINDEX

Name

REINDEX  --  Rebuilds indexes on tables.

Synopsis

REINDEX { TABLE | DATABASE | INDEX } name [ FORCE ]
  

Parameters

TABLE

Pass this parameter to specify that you want to rebuild the indexes of a specified table.

DATABASE

Pass this parameter to rebuild all system indexes for a specified database.

INDEX

Pass this parameter to rebuild a specified index.

name

Use this parameter to specify the name of the object you wish to reindex.

FORCE

Pass this parameter to force the rebuilding of an index. If this parameter is not given, the REINDEX command will only rebuild invalidated indexes.

Results

REINDEX

This message is displayed if the target object is successfully reindexed.

Description

Use the REINDEX command to rebuild any indexes that become corrupt or invalidated. This is especially useful if the system indexes become corrupted. To fix them, shutdown postmaster and start a standalone database server by restarting it with the -O and -P command line options. This opens a standalone server that ignores all system indexes. Run the REINDEX command once you are at the PostgreSQL prompt.

Examples

The following example will recreate the publishers table.

     REINDEX TABLE publishers;