Reindex
Rebuilds indices on tables.
Synopsis
REINDEX { TABLE | DATABASE | INDEX } name [ FORCE ]
Parameters
TABLE | DATABASE | INDEX
The type of database object to be re-indexed.
name
The name of the database object you wish to re-index.
FORCE
The
FORCE
keyword forces the rebuilding of all specified indices. If this parameter is not given, theREINDEX
command will rebuild only invalidated indices.
Results
REINDEX
The message returned when a target object is successfully reindexed.
Description
Use the REINDEX
command to rebuild any indices that have become
corrupt. This is especially useful if system indices become corrupted. To fix them, shutdown
postmaster and start it using the -o â-O -Pâ
command-line parameter. This opens a standalone server that allows for re-indexing of system
indices. Run the REINDEX DATABASE
command once you are at the
psql prompt.
Examples
The following example rebuilds all indices on the books
table, within
the booktown
database:
booktown=# REINDEX TABLE books;
REINDEX
Get Practical PostgreSQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.