1REINDEXDB(1)             PostgreSQL 13.3 Documentation            REINDEXDB(1)
2
3
4

NAME

6       reindexdb - reindex a PostgreSQL database
7

SYNOPSIS

9       reindexdb [connection-option...] [option...]
10                 [ -S | --schema schema ]...  [ -t | --table table ]...
11                 [ -i | --index index ]...  [dbname]
12
13       reindexdb [connection-option...] [option...] -a | --all
14
15       reindexdb [connection-option...] [option...] -s | --system  [dbname]
16

DESCRIPTION

18       reindexdb is a utility for rebuilding indexes in a PostgreSQL database.
19
20       reindexdb is a wrapper around the SQL command REINDEX(7). There is no
21       effective difference between reindexing databases via this utility and
22       via other methods for accessing the server.
23

OPTIONS

25       reindexdb accepts the following command-line arguments:
26
27       -a
28       --all
29           Reindex all databases.
30
31       --concurrently
32           Use the CONCURRENTLY option. See REINDEX(7), where all the caveats
33           of this option are explained in detail.
34
35       [-d] dbname
36       [--dbname=]dbname
37           Specifies the name of the database to be reindexed, when -a/--all
38           is not used. If this is not specified, the database name is read
39           from the environment variable PGDATABASE. If that is not set, the
40           user name specified for the connection is used. The dbname can be a
41           connection string. If so, connection string parameters will
42           override any conflicting command line options.
43
44       -e
45       --echo
46           Echo the commands that reindexdb generates and sends to the server.
47
48       -i index
49       --index=index
50           Recreate index only. Multiple indexes can be recreated by writing
51           multiple -i switches.
52
53       -j njobs
54       --jobs=njobs
55           Execute the reindex commands in parallel by running njobs commands
56           simultaneously. This option may reduce the processing time but it
57           also increases the load on the database server.
58
59           reindexdb will open njobs connections to the database, so make sure
60           your max_connections setting is high enough to accommodate all
61           connections.
62
63           Note that this option is incompatible with the --index and --system
64           options.
65
66       -q
67       --quiet
68           Do not display progress messages.
69
70       -s
71       --system
72           Reindex database's system catalogs.
73
74       -S schema
75       --schema=schema
76           Reindex schema only. Multiple schemas can be reindexed by writing
77           multiple -S switches.
78
79       -t table
80       --table=table
81           Reindex table only. Multiple tables can be reindexed by writing
82           multiple -t switches.
83
84       -v
85       --verbose
86           Print detailed information during processing.
87
88       -V
89       --version
90           Print the reindexdb version and exit.
91
92       -?
93       --help
94           Show help about reindexdb command line arguments, and exit.
95
96       reindexdb also accepts the following command-line arguments for
97       connection parameters:
98
99       -h host
100       --host=host
101           Specifies the host name of the machine on which the server is
102           running. If the value begins with a slash, it is used as the
103           directory for the Unix domain socket.
104
105       -p port
106       --port=port
107           Specifies the TCP port or local Unix domain socket file extension
108           on which the server is listening for connections.
109
110       -U username
111       --username=username
112           User name to connect as.
113
114       -w
115       --no-password
116           Never issue a password prompt. If the server requires password
117           authentication and a password is not available by other means such
118           as a .pgpass file, the connection attempt will fail. This option
119           can be useful in batch jobs and scripts where no user is present to
120           enter a password.
121
122       -W
123       --password
124           Force reindexdb to prompt for a password before connecting to a
125           database.
126
127           This option is never essential, since reindexdb will automatically
128           prompt for a password if the server demands password
129           authentication. However, reindexdb will waste a connection attempt
130           finding out that the server wants a password. In some cases it is
131           worth typing -W to avoid the extra connection attempt.
132
133       --maintenance-db=dbname
134           Specifies the name of the database to connect to to discover which
135           databases should be reindexed, when -a/--all is used. If not
136           specified, the postgres database will be used, or if that does not
137           exist, template1 will be used. This can be a connection string. If
138           so, connection string parameters will override any conflicting
139           command line options. Also, connection string parameters other than
140           the database name itself will be re-used when connecting to other
141           databases.
142

ENVIRONMENT

144       PGDATABASE
145       PGHOST
146       PGPORT
147       PGUSER
148           Default connection parameters
149
150       PG_COLOR
151           Specifies whether to use color in diagnostic messages. Possible
152           values are always, auto and never.
153
154       This utility, like most other PostgreSQL utilities, also uses the
155       environment variables supported by libpq (see Section 33.14).
156

DIAGNOSTICS

158       In case of difficulty, see REINDEX(7) and psql(1) for discussions of
159       potential problems and error messages. The database server must be
160       running at the targeted host. Also, any default connection settings and
161       environment variables used by the libpq front-end library will apply.
162

NOTES

164       reindexdb might need to connect several times to the PostgreSQL server,
165       asking for a password each time. It is convenient to have a ~/.pgpass
166       file in such cases. See Section 33.15 for more information.
167

EXAMPLES

169       To reindex the database test:
170
171           $ reindexdb test
172
173       To reindex the table foo and the index bar in a database named abcd:
174
175           $ reindexdb --table=foo --index=bar abcd
176

SEE ALSO

178       REINDEX(7)
179
180
181
182PostgreSQL 13.3                      2021                         REINDEXDB(1)
Impressum