| 1 |
<!-- |
| 2 |
doc/src/sgml/ref/reindexdb.sgml |
| 3 |
PostgreSQL documentation |
| 4 |
--> |
| 5 |
|
| 6 |
<refentry id="app-reindexdb"> |
| 7 |
<indexterm zone="app-reindexdb"> |
| 8 |
<primary>reindexdb</primary> |
| 9 |
</indexterm> |
| 10 |
|
| 11 |
<refmeta> |
| 12 |
<refentrytitle><application>reindexdb</application></refentrytitle> |
| 13 |
<manvolnum>1</manvolnum> |
| 14 |
<refmiscinfo>Application</refmiscinfo> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>reindexdb</refname> |
| 19 |
<refpurpose>reindex a <productname>PostgreSQL</productname> database</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<cmdsynopsis> |
| 24 |
<command>reindexdb</command> |
| 25 |
<arg rep="repeat"><replaceable>connection-option</replaceable></arg> |
| 26 |
<arg rep="repeat"><replaceable>option</replaceable></arg> |
| 27 |
|
| 28 |
<arg choice="plain" rep="repeat"> |
| 29 |
<arg choice="opt"> |
| 30 |
<group choice="plain"> |
| 31 |
<arg choice="plain"><option>-S</option></arg> |
| 32 |
<arg choice="plain"><option>--schema</option></arg> |
| 33 |
</group> |
| 34 |
<replaceable>schema</replaceable> |
| 35 |
</arg> |
| 36 |
</arg> |
| 37 |
|
| 38 |
<arg choice="plain" rep="repeat"> |
| 39 |
<arg choice="opt"> |
| 40 |
<group choice="plain"> |
| 41 |
<arg choice="plain"><option>-t</option></arg> |
| 42 |
<arg choice="plain"><option>--table</option></arg> |
| 43 |
</group> |
| 44 |
<replaceable>table</replaceable> |
| 45 |
</arg> |
| 46 |
</arg> |
| 47 |
|
| 48 |
<arg choice="plain" rep="repeat"> |
| 49 |
<arg choice="opt"> |
| 50 |
<group choice="plain"> |
| 51 |
<arg choice="plain"><option>-i</option></arg> |
| 52 |
<arg choice="plain"><option>--index</option></arg> |
| 53 |
</group> |
| 54 |
<replaceable>index</replaceable> |
| 55 |
</arg> |
| 56 |
</arg> |
| 57 |
|
| 58 |
<arg choice="plain"> |
| 59 |
<arg choice="opt"> |
| 60 |
<group choice="plain"> |
| 61 |
<arg choice="plain"><option>-s</option></arg> |
| 62 |
<arg choice="plain"><option>--system</option></arg> |
| 63 |
</group> |
| 64 |
</arg> |
| 65 |
</arg> |
| 66 |
|
| 67 |
<arg choice="opt"> |
| 68 |
<group choice="plain"> |
| 69 |
<arg choice="plain"><replaceable>dbname</replaceable></arg> |
| 70 |
<arg choice="plain"><option>-a</option></arg> |
| 71 |
<arg choice="plain"><option>--all</option></arg> |
| 72 |
</group> |
| 73 |
</arg> |
| 74 |
</cmdsynopsis> |
| 75 |
</refsynopsisdiv> |
| 76 |
|
| 77 |
|
| 78 |
<refsect1> |
| 79 |
<title>Description</title> |
| 80 |
|
| 81 |
<para> |
| 82 |
<application>reindexdb</application> is a utility for rebuilding indexes |
| 83 |
in a <productname>PostgreSQL</productname> database. |
| 84 |
</para> |
| 85 |
|
| 86 |
<para> |
| 87 |
<application>reindexdb</application> is a wrapper around the SQL |
| 88 |
command <link linkend="sql-reindex"><command>REINDEX</command></link>. |
| 89 |
There is no effective difference between reindexing databases via |
| 90 |
this utility and via other methods for accessing the server. |
| 91 |
</para> |
| 92 |
|
| 93 |
</refsect1> |
| 94 |
|
| 95 |
|
| 96 |
<refsect1> |
| 97 |
<title>Options</title> |
| 98 |
|
| 99 |
<para> |
| 100 |
<application>reindexdb</application> accepts the following command-line arguments: |
| 101 |
|
| 102 |
<variablelist> |
| 103 |
<varlistentry> |
| 104 |
<term><option>-a</option></term> |
| 105 |
<term><option>--all</option></term> |
| 106 |
<listitem> |
| 107 |
<para> |
| 108 |
Reindex all databases. |
| 109 |
</para> |
| 110 |
</listitem> |
| 111 |
</varlistentry> |
| 112 |
|
| 113 |
<varlistentry> |
| 114 |
<term><option>--concurrently</option></term> |
| 115 |
<listitem> |
| 116 |
<para> |
| 117 |
Use the <literal>CONCURRENTLY</literal> option. See |
| 118 |
<xref linkend="sql-reindex"/>, where all the caveats of this option |
| 119 |
are explained in detail. |
| 120 |
</para> |
| 121 |
</listitem> |
| 122 |
</varlistentry> |
| 123 |
|
| 124 |
<varlistentry> |
| 125 |
<term><option><optional>-d</optional> <replaceable class="parameter">dbname</replaceable></option></term> |
| 126 |
<term><option><optional>--dbname=</optional><replaceable class="parameter">dbname</replaceable></option></term> |
| 127 |
<listitem> |
| 128 |
<para> |
| 129 |
Specifies the name of the database to be reindexed, |
| 130 |
when <option>-a</option>/<option>--all</option> is not used. |
| 131 |
If this is not specified, the database name is read |
| 132 |
from the environment variable <envar>PGDATABASE</envar>. If |
| 133 |
that is not set, the user name specified for the connection is |
| 134 |
used. The <replaceable>dbname</replaceable> can be a <link |
| 135 |
linkend="libpq-connstring">connection string</link>. If so, |
| 136 |
connection string parameters will override any conflicting command |
| 137 |
line options. |
| 138 |
</para> |
| 139 |
</listitem> |
| 140 |
</varlistentry> |
| 141 |
|
| 142 |
<varlistentry> |
| 143 |
<term><option>-e</option></term> |
| 144 |
<term><option>--echo</option></term> |
| 145 |
<listitem> |
| 146 |
<para> |
| 147 |
Echo the commands that <application>reindexdb</application> generates |
| 148 |
and sends to the server. |
| 149 |
</para> |
| 150 |
</listitem> |
| 151 |
</varlistentry> |
| 152 |
|
| 153 |
<varlistentry> |
| 154 |
<term><option>-i <replaceable class="parameter">index</replaceable></option></term> |
| 155 |
<term><option>--index=<replaceable class="parameter">index</replaceable></option></term> |
| 156 |
<listitem> |
| 157 |
<para> |
| 158 |
Recreate <replaceable class="parameter">index</replaceable> only. |
| 159 |
Multiple indexes can be recreated by writing multiple |
| 160 |
<option>-i</option> switches. |
| 161 |
</para> |
| 162 |
</listitem> |
| 163 |
</varlistentry> |
| 164 |
|
| 165 |
<varlistentry> |
| 166 |
<term><option>-j <replaceable class="parameter">njobs</replaceable></option></term> |
| 167 |
<term><option>--jobs=<replaceable class="parameter">njobs</replaceable></option></term> |
| 168 |
<listitem> |
| 169 |
<para> |
| 170 |
Execute the reindex commands in parallel by running |
| 171 |
<replaceable class="parameter">njobs</replaceable> |
| 172 |
commands simultaneously. This option may reduce the processing time |
| 173 |
but it also increases the load on the database server. |
| 174 |
</para> |
| 175 |
<para> |
| 176 |
<application>reindexdb</application> will open |
| 177 |
<replaceable class="parameter">njobs</replaceable> connections to the |
| 178 |
database, so make sure your <xref linkend="guc-max-connections"/> |
| 179 |
setting is high enough to accommodate all connections. |
| 180 |
</para> |
| 181 |
<para> |
| 182 |
Note that this option is incompatible with the <option>--system</option> option. |
| 183 |
</para> |
| 184 |
</listitem> |
| 185 |
</varlistentry> |
| 186 |
|
| 187 |
<varlistentry> |
| 188 |
<term><option>-q</option></term> |
| 189 |
<term><option>--quiet</option></term> |
| 190 |
<listitem> |
| 191 |
<para> |
| 192 |
Do not display progress messages. |
| 193 |
</para> |
| 194 |
</listitem> |
| 195 |
</varlistentry> |
| 196 |
|
| 197 |
<varlistentry> |
| 198 |
<term><option>-s</option></term> |
| 199 |
<term><option>--system</option></term> |
| 200 |
<listitem> |
| 201 |
<para> |
| 202 |
Reindex database's system catalogs only. |
| 203 |
</para> |
| 204 |
</listitem> |
| 205 |
</varlistentry> |
| 206 |
|
| 207 |
<varlistentry> |
| 208 |
<term><option>-S <replaceable class="parameter">schema</replaceable></option></term> |
| 209 |
<term><option>--schema=<replaceable class="parameter">schema</replaceable></option></term> |
| 210 |
<listitem> |
| 211 |
<para> |
| 212 |
Reindex <replaceable class="parameter">schema</replaceable> only. |
| 213 |
Multiple schemas can be reindexed by writing multiple |
| 214 |
<option>-S</option> switches. |
| 215 |
</para> |
| 216 |
</listitem> |
| 217 |
</varlistentry> |
| 218 |
|
| 219 |
<varlistentry> |
| 220 |
<term><option>-t <replaceable class="parameter">table</replaceable></option></term> |
| 221 |
<term><option>--table=<replaceable class="parameter">table</replaceable></option></term> |
| 222 |
<listitem> |
| 223 |
<para> |
| 224 |
Reindex <replaceable class="parameter">table</replaceable> only. |
| 225 |
Multiple tables can be reindexed by writing multiple |
| 226 |
<option>-t</option> switches. |
| 227 |
</para> |
| 228 |
</listitem> |
| 229 |
</varlistentry> |
| 230 |
|
| 231 |
<varlistentry> |
| 232 |
<term><option>--tablespace=<replaceable class="parameter">tablespace</replaceable></option></term> |
| 233 |
<listitem> |
| 234 |
<para> |
| 235 |
Specifies the tablespace where indexes are rebuilt. (This name is |
| 236 |
processed as a double-quoted identifier.) |
| 237 |
</para> |
| 238 |
</listitem> |
| 239 |
</varlistentry> |
| 240 |
|
| 241 |
<varlistentry> |
| 242 |
<term><option>-v</option></term> |
| 243 |
<term><option>--verbose</option></term> |
| 244 |
<listitem> |
| 245 |
<para> |
| 246 |
Print detailed information during processing. |
| 247 |
</para> |
| 248 |
</listitem> |
| 249 |
</varlistentry> |
| 250 |
|
| 251 |
<varlistentry> |
| 252 |
<term><option>-V</option></term> |
| 253 |
<term><option>--version</option></term> |
| 254 |
<listitem> |
| 255 |
<para> |
| 256 |
Print the <application>reindexdb</application> version and exit. |
| 257 |
</para> |
| 258 |
</listitem> |
| 259 |
</varlistentry> |
| 260 |
|
| 261 |
<varlistentry> |
| 262 |
<term><option>-?</option></term> |
| 263 |
<term><option>--help</option></term> |
| 264 |
<listitem> |
| 265 |
<para> |
| 266 |
Show help about <application>reindexdb</application> command line |
| 267 |
arguments, and exit. |
| 268 |
</para> |
| 269 |
</listitem> |
| 270 |
</varlistentry> |
| 271 |
|
| 272 |
</variablelist> |
| 273 |
|
| 274 |
</para> |
| 275 |
|
| 276 |
<para> |
| 277 |
<application>reindexdb</application> also accepts |
| 278 |
the following command-line arguments for connection parameters: |
| 279 |
|
| 280 |
<variablelist> |
| 281 |
<varlistentry> |
| 282 |
<term><option>-h <replaceable class="parameter">host</replaceable></option></term> |
| 283 |
<term><option>--host=<replaceable class="parameter">host</replaceable></option></term> |
| 284 |
<listitem> |
| 285 |
<para> |
| 286 |
Specifies the host name of the machine on which the server is |
| 287 |
running. If the value begins with a slash, it is used as the |
| 288 |
directory for the Unix domain socket. |
| 289 |
</para> |
| 290 |
</listitem> |
| 291 |
</varlistentry> |
| 292 |
|
| 293 |
<varlistentry> |
| 294 |
<term><option>-p <replaceable class="parameter">port</replaceable></option></term> |
| 295 |
<term><option>--port=<replaceable class="parameter">port</replaceable></option></term> |
| 296 |
<listitem> |
| 297 |
<para> |
| 298 |
Specifies the TCP port or local Unix domain socket file |
| 299 |
extension on which the server |
| 300 |
is listening for connections. |
| 301 |
</para> |
| 302 |
</listitem> |
| 303 |
</varlistentry> |
| 304 |
|
| 305 |
<varlistentry> |
| 306 |
<term><option>-U <replaceable class="parameter">username</replaceable></option></term> |
| 307 |
<term><option>--username=<replaceable class="parameter">username</replaceable></option></term> |
| 308 |
<listitem> |
| 309 |
<para> |
| 310 |
User name to connect as. |
| 311 |
</para> |
| 312 |
</listitem> |
| 313 |
</varlistentry> |
| 314 |
|
| 315 |
<varlistentry> |
| 316 |
<term><option>-w</option></term> |
| 317 |
<term><option>--no-password</option></term> |
| 318 |
<listitem> |
| 319 |
<para> |
| 320 |
Never issue a password prompt. If the server requires |
| 321 |
password authentication and a password is not available by |
| 322 |
other means such as a <filename>.pgpass</filename> file, the |
| 323 |
connection attempt will fail. This option can be useful in |
| 324 |
batch jobs and scripts where no user is present to enter a |
| 325 |
password. |
| 326 |
</para> |
| 327 |
</listitem> |
| 328 |
</varlistentry> |
| 329 |
|
| 330 |
<varlistentry> |
| 331 |
<term><option>-W</option></term> |
| 332 |
<term><option>--password</option></term> |
| 333 |
<listitem> |
| 334 |
<para> |
| 335 |
Force <application>reindexdb</application> to prompt for a |
| 336 |
password before connecting to a database. |
| 337 |
</para> |
| 338 |
|
| 339 |
<para> |
| 340 |
This option is never essential, since |
| 341 |
<application>reindexdb</application> will automatically prompt |
| 342 |
for a password if the server demands password authentication. |
| 343 |
However, <application>reindexdb</application> will waste a |
| 344 |
connection attempt finding out that the server wants a password. |
| 345 |
In some cases it is worth typing <option>-W</option> to avoid the extra |
| 346 |
connection attempt. |
| 347 |
</para> |
| 348 |
</listitem> |
| 349 |
</varlistentry> |
| 350 |
|
| 351 |
<varlistentry> |
| 352 |
<term><option>--maintenance-db=<replaceable class="parameter">dbname</replaceable></option></term> |
| 353 |
<listitem> |
| 354 |
<para> |
| 355 |
When the <option>-a</option>/<option>--all</option> is used, connect |
| 356 |
to this database to gather the list of databases to reindex. |
| 357 |
If not specified, the <literal>postgres</literal> database will be used, |
| 358 |
or if that does not exist, <literal>template1</literal> will be used. |
| 359 |
This can be a <link linkend="libpq-connstring">connection |
| 360 |
string</link>. If so, connection string parameters will override any |
| 361 |
conflicting command line options. Also, connection string parameters |
| 362 |
other than the database name itself will be re-used when connecting |
| 363 |
to other databases. |
| 364 |
</para> |
| 365 |
</listitem> |
| 366 |
</varlistentry> |
| 367 |
</variablelist> |
| 368 |
</para> |
| 369 |
</refsect1> |
| 370 |
|
| 371 |
|
| 372 |
<refsect1> |
| 373 |
<title>Environment</title> |
| 374 |
|
| 375 |
<variablelist> |
| 376 |
<varlistentry> |
| 377 |
<term><envar>PGDATABASE</envar></term> |
| 378 |
<term><envar>PGHOST</envar></term> |
| 379 |
<term><envar>PGPORT</envar></term> |
| 380 |
<term><envar>PGUSER</envar></term> |
| 381 |
|
| 382 |
<listitem> |
| 383 |
<para> |
| 384 |
Default connection parameters |
| 385 |
</para> |
| 386 |
</listitem> |
| 387 |
</varlistentry> |
| 388 |
|
| 389 |
<varlistentry> |
| 390 |
<term><envar>PG_COLOR</envar></term> |
| 391 |
<listitem> |
| 392 |
<para> |
| 393 |
Specifies whether to use color in diagnostic messages. Possible values |
| 394 |
are <literal>always</literal>, <literal>auto</literal> and |
| 395 |
<literal>never</literal>. |
| 396 |
</para> |
| 397 |
</listitem> |
| 398 |
</varlistentry> |
| 399 |
</variablelist> |
| 400 |
|
| 401 |
<para> |
| 402 |
This utility, like most other <productname>PostgreSQL</productname> utilities, |
| 403 |
also uses the environment variables supported by <application>libpq</application> |
| 404 |
(see <xref linkend="libpq-envars"/>). |
| 405 |
</para> |
| 406 |
|
| 407 |
</refsect1> |
| 408 |
|
| 409 |
|
| 410 |
<refsect1> |
| 411 |
<title>Diagnostics</title> |
| 412 |
|
| 413 |
<para> |
| 414 |
In case of difficulty, see <xref linkend="sql-reindex"/> |
| 415 |
and <xref linkend="app-psql"/> for |
| 416 |
discussions of potential problems and error messages. |
| 417 |
The database server must be running at the |
| 418 |
targeted host. Also, any default connection settings and environment |
| 419 |
variables used by the <application>libpq</application> front-end |
| 420 |
library will apply. |
| 421 |
</para> |
| 422 |
|
| 423 |
</refsect1> |
| 424 |
|
| 425 |
<refsect1> |
| 426 |
<title>Examples</title> |
| 427 |
|
| 428 |
<para> |
| 429 |
To reindex the database <literal>test</literal>: |
| 430 |
<screen> |
| 431 |
<prompt>$ </prompt><userinput>reindexdb test</userinput> |
| 432 |
</screen> |
| 433 |
</para> |
| 434 |
|
| 435 |
<para> |
| 436 |
To reindex the table <literal>foo</literal> and the index |
| 437 |
<literal>bar</literal> in a database named <literal>abcd</literal>: |
| 438 |
<screen> |
| 439 |
<prompt>$ </prompt><userinput>reindexdb --table=foo --index=bar abcd</userinput> |
| 440 |
</screen></para> |
| 441 |
|
| 442 |
</refsect1> |
| 443 |
|
| 444 |
<refsect1> |
| 445 |
<title>See Also</title> |
| 446 |
|
| 447 |
<simplelist type="inline"> |
| 448 |
<member><xref linkend="sql-reindex"/></member> |
| 449 |
</simplelist> |
| 450 |
</refsect1> |
| 451 |
|
| 452 |
</refentry> |