REINDEXDB(1)

πŸ“¦ version 17.11, in opensuse-leap 16.0

✨ 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 the CONCURRENTLY option. See REINDEX(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/--all is not used. If this is not specified, the database name is read from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is used. The dbname can 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 that reindexdb generates 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 -i switches. Like, you can just keep adding -i and it'll do all the indexes. Slay.
  • -j njobs, --jobs=njobs β€” Execute the reindex commands in parallel by running njobs commands simultaneously. This option may reduce the processing time but it also increases the load on the database server. reindexdb will open njobs connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Note that this option is incompatible with the --system option. 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 -S switches. Just keep stacking them. Stack 'em up.
  • -t table, --table=table β€” Reindex table only. Multiple tables can be reindexed by writing multiple -t switches. 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 the reindexdb version and exit. Just the version. That's it. That's the tweet.
  • -?, --help β€” Show help about reindexdb command 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/postgresql or 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 .pgpass 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. So it's for the automation girlies. πŸ€–
  • -W, --password β€” Force reindexdb to prompt for a password before connecting to a database. This option is never essential, since reindexdb will automatically prompt for a password if the server demands password authentication. However, reindexdb will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. So it's like, a preemptive move. Not required but sometimes smart. ✨
  • --maintenance-db=dbname β€” When the -a/--all is used, connect to this database to gather the list of databases to reindex. If not specified, the postgres database will be used, or if that does not exist, template1 will 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 🌈

  • PGDATABASE
  • PGHOST
  • PGPORT
  • PGUSER

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 are always, auto and never. 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