3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "REINDEXDB" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 reindexdb \- reindex a PostgreSQL database
33 .HP \w'\fBreindexdb\fR\ 'u
34 \fBreindexdb\fR [\fIconnection\-option\fR...] [\fIoption\fR...] [\ \fB\-S\fR\ |\ \fB\-\-schema\fR\ \fIschema\fR\ ]... [\ \fB\-t\fR\ |\ \fB\-\-table\fR\ \fItable\fR\ ]... [\ \fB\-i\fR\ |\ \fB\-\-index\fR\ \fIindex\fR\ ]... [\ \fB\-s\fR\ |\ \fB\-\-system\fR\ ] [\fIdbname\fR\ |\ \fB\-a\fR\ |\ \fB\-\-all\fR]
38 is a utility for rebuilding indexes in a
43 is a wrapper around the SQL command
44 \fBREINDEX\fR\&. There is no effective difference between reindexing databases via this utility and via other methods for accessing the server\&.
48 accepts the following command\-line arguments:
54 Reindex all databases\&.
57 \fB\-\-concurrently\fR
62 \fBREINDEX\fR(7), where all the caveats of this option are explained in detail\&.
65 \fB[\-d]\fR\fB \fR\fB\fIdbname\fR\fR
67 \fB[\-\-dbname=]\fR\fB\fIdbname\fR\fR
69 Specifies the name of the database to be reindexed, when
70 \fB\-a\fR/\fB\-\-all\fR
71 is not used\&. If this is not specified, the database name is read from the environment variable
72 \fBPGDATABASE\fR\&. If that is not set, the user name specified for the connection is used\&. The
75 connection string\&. If so, connection string parameters will override any conflicting command line options\&.
82 Echo the commands that
84 generates and sends to the server\&.
87 \fB\-i \fR\fB\fIindex\fR\fR
89 \fB\-\-index=\fR\fB\fIindex\fR\fR
93 only\&. Multiple indexes can be recreated by writing multiple
98 \fB\-j \fR\fB\fInjobs\fR\fR
100 \fB\-\-jobs=\fR\fB\fInjobs\fR\fR
102 Execute the reindex commands in parallel by running
104 commands simultaneously\&. This option may reduce the processing time but it also increases the load on the database server\&.
109 connections to the database, so make sure your
111 setting is high enough to accommodate all connections\&.
113 Note that this option is incompatible with the
122 Do not display progress messages\&.
129 Reindex database\*(Aqs system catalogs only\&.
132 \fB\-S \fR\fB\fIschema\fR\fR
134 \fB\-\-schema=\fR\fB\fIschema\fR\fR
138 only\&. Multiple schemas can be reindexed by writing multiple
143 \fB\-t \fR\fB\fItable\fR\fR
145 \fB\-\-table=\fR\fB\fItable\fR\fR
149 only\&. Multiple tables can be reindexed by writing multiple
154 \fB\-\-tablespace=\fR\fB\fItablespace\fR\fR
156 Specifies the tablespace where indexes are rebuilt\&. (This name is processed as a double\-quoted identifier\&.)
163 Print detailed information during processing\&.
181 command line arguments, and exit\&.
185 also accepts the following command\-line arguments for connection parameters:
187 \fB\-h \fR\fB\fIhost\fR\fR
189 \fB\-\-host=\fR\fB\fIhost\fR\fR
191 Specifies the host name of the machine on which the server is running\&. If the value begins with a slash, it is used as the directory for the Unix domain socket\&.
194 \fB\-p \fR\fB\fIport\fR\fR
196 \fB\-\-port=\fR\fB\fIport\fR\fR
198 Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections\&.
201 \fB\-U \fR\fB\fIusername\fR\fR
203 \fB\-\-username=\fR\fB\fIusername\fR\fR
205 User name to connect as\&.
210 \fB\-\-no\-password\fR
212 Never issue a password prompt\&. If the server requires password authentication and a password is not available by other means such as a
214 file, the connection attempt will fail\&. This option can be useful in batch jobs and scripts where no user is present to enter a password\&.
223 to prompt for a password before connecting to a database\&.
225 This option is never essential, since
227 will automatically prompt for a password if the server demands password authentication\&. However,
229 will waste a connection attempt finding out that the server wants a password\&. In some cases it is worth typing
231 to avoid the extra connection attempt\&.
234 \fB\-\-maintenance\-db=\fR\fB\fIdbname\fR\fR
237 \fB\-a\fR/\fB\-\-all\fR
238 is used, connect to this database to gather the list of databases to reindex\&. If not specified, the
240 database will be used, or if that does not exist,
242 will be used\&. This can be a
243 connection string\&. If so, connection string parameters will override any conflicting command line options\&. Also, connection string parameters other than the database name itself will be re\-used when connecting to other databases\&.
255 Default connection parameters
260 Specifies whether to use color in diagnostic messages\&. Possible values are
267 This utility, like most other
269 utilities, also uses the environment variables supported by
275 In case of difficulty, see
279 for discussions of potential problems and error messages\&. The database server must be running at the targeted host\&. Also, any default connection settings and environment variables used by the
281 front\-end library will apply\&.
284 To reindex the database
291 $ \fBreindexdb test\fR
308 $ \fBreindexdb \-\-table=foo \-\-index=bar abcd\fR