REINDEXDB(1)
β¨ REINDEXDB(1) β reindex a PostgreSQL database, but make it cute β¨
Okay so bestie, this is the manual page for reindexdb, the PostgreSQL utility that rebuilds indexes in a database. It's from PostgreSQL 17.11, so you know it's fresh. Let's get into it. π
π¦ SYNOPSIS π¦
reindexdb [connection-option...] [option...] [ -S | --schema schema ]...
[ -t | --table table ]... [ -i | --index index ]...
[ -s | --system ] [dbname | -a | --all]
πΈ DESCRIPTION πΈ
reindexdb is a utility for rebuilding indexes in a PostgreSQL database. That's the whole vibe. It's a wrapper around the SQL command REINDEX. There is no effective difference between reindexing databases via this utility and via other methods for accessing the server. None. Zero. Nada. Periodt.
π OPTIONS π
reindexdb accepts the following command-line arguments:
-a,--allβ Reindex all databases. All of them. Every single one. π--concurrentlyβ Use theCONCURRENTLYoption. SeeREINDEX(7), where all the caveats of this option are explained in detail. And bestie, there are caveats. Read them. No cap.[-d] dbname,[--dbname=]dbnameβ Specifies the name of the database to be reindexed, when-a/--allis not used. If this is not specified, the database name is read from the environment variablePGDATABASE. If that is not set, the user name specified for the connection is used. Thedbnamecan be a connection string. If so, connection string parameters will override any conflicting command line options. So if you're using a connection string, it takes priority. Slay.-e,--echoβ Echo the commands thatreindexdbgenerates and sends to the server. So you can see exactly what it's doing. Iconic for debugging.-i index,--index=indexβ Recreate index only. Multiple indexes can be recreated by writing multiple-iswitches. Like, you can just keep adding-iand it'll do all the indexes. Slay.-j njobs,--jobs=njobsβ Execute the reindex commands in parallel by runningnjobscommands simultaneously. This option may reduce the processing time but it also increases the load on the database server.reindexdbwill opennjobsconnections to the database, so make sure yourmax_connectionssetting is high enough to accommodate all connections. Note that this option is incompatible with the--systemoption. So don't mix them, okay? π-q,--quietβ Do not display progress messages. For when you just want it to do the thing without all the chatter. Shhh.-s,--systemβ Reindex database's system catalogs only. Just the system stuff. Not the regular stuff.-S schema,--schema=schemaβ Reindex schema only. Multiple schemas can be reindexed by writing multiple-Sswitches. Just keep stacking them. Stack 'em up.-t table,--table=tableβ Reindex table only. Multiple tables can be reindexed by writing multiple-tswitches. Same energy. Stack 'em. Stack 'em up.--tablespace=tablespaceβ Specifies the tablespace where indexes are rebuilt. (This name is processed as a double-quoted identifier.) So watch out for that quoting. iykyk.-v,--verboseβ Print detailed information during processing. For the folks who need to see every step. No shame. We love transparency.-V,--versionβ Print thereindexdbversion and exit. Just the version. That's it. That's the tweet.-?,--helpβ Show help aboutreindexdbcommand line arguments, and exit. The classic. Always here for you.
reindexdb also accepts the following command-line arguments for connection parameters:
-h host,--host=hostβ 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. So like,/var/run/postgresqlor whatever. You know the vibe. Unix domain socket realness.-p port,--port=portβ Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. The port. The number. You got this. π’-U username,--username=usernameβ User name to connect as. Who are you? Be that person. Main character energy.-w,--no-passwordβ Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a.pgpassfile, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. So it's for the automation girlies. π€-W,--passwordβ Forcereindexdbto prompt for a password before connecting to a database. This option is never essential, sincereindexdbwill automatically prompt for a password if the server demands password authentication. However,reindexdbwill waste a connection attempt finding out that the server wants a password. In some cases it is worth typing-Wto avoid the extra connection attempt. So it's like, a preemptive move. Not required but sometimes smart. β¨--maintenance-db=dbnameβ When the-a/--allis used, connect to this database to gather the list of databases to reindex. If not specified, thepostgresdatabase will be used, or if that does not exist,template1will be used. This can be a 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. So it's like the main character database that helps orchestrate the rest. π
π ENVIRONMENT π
PGDATABASEPGHOSTPGPORTPGUSER
These are the default connection parameters. You probably already know them. But here they are. Just in case.
PG_COLORβ Specifies whether to use color in diagnostic messages. Possible values arealways,autoandnever. So you can make your errors pretty if you want. Pretty errors > boring errors.
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15). So there's more where that came from. libpq is the plug.
π DIAGNOSTICS π
In case of difficulty, see REINDEX(7) and psql(1) 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 libpq front-end library will apply. So yeah, check the usual suspects. If something's broken, it's probably that.
π EXAMPLES π
To reindex the database test:
$ reindexdb test
To reindex the table foo and the index bar in a database named abcd:
$ reindexdb --table=foo --index=bar abcd
See? Easy. You got this. π
π§ SEE ALSO π§
REINDEX(7) β that's the one. The SQL command. Go read it if you want the deep lore. iykyk.
And that's the whole manual, bestie. Stay slay, keep your indexes fresh, and remember: PostgreSQL 17.11, 2026, REINDEXDB(1). π β¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms