CLUSTERDB(1)
πΈ NAME πΈ
okay so bestie, meet clusterdb(1) β the PostgreSQL utility that gives your tables a lil recluster moment. Weβre gonna walk through every flag, every env var, and every caveat together. No cap, nothing skipped. π
β¨ SYNOPSIS β¨
clusterdb [connection-option...] [--verbose | -v]
[ --table | -t table ]... [dbname]
clusterdb [connection-option...] [--verbose | -v] --all | -a
π DESCRIPTION π
clusterdb is a utility for reclustering tables in a PostgreSQL database. It finds tables that have previously been clustered, and clusters them again on the same index that was last used. Tables that have never been clustered are not affected. periodt π
clusterdb is a wrapper around the SQL command CLUSTER(7). There is no effective difference between clustering databases via this utility and via other methods for accessing the server. Same energy, same result. β¨
π OPTIONS π
clusterdb accepts the following command-line arguments:
-a,--allβ cluster all databases. all of them, bestie π[-d] dbname,[--dbname=]dbnameβ picks the database to cluster 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. The dbname can be a connection string β if so, connection string parameters will override any conflicting command line options. π«Ά-e,--echoβ echo the commands thatclusterdbgenerates and sends to the server. Itβs literally spilling the server tea. β-q,--quietβ do not display progress messages. Shhh, quiet girl era. π€«-t table,--table=tableβ cluster table only. Multiple tables can be clustered by writing multiple-tswitches. π―-v,--verboseβ print detailed information during processing. Info dump, but make it cute. π-V,--versionβ print theclusterdbversion and exit. π«-?,--helpβ show help aboutclusterdbcommand-line arguments, and exit. π
It also accepts these 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. π₯οΈ-p port,--port=portβ specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. π-U username,--username=usernameβ user name to connect as. πͺͺ-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. > vibe check: no password prompt means no magical backup password, okay? π-W,--passwordβ forceclusterdbto prompt for a password before connecting to a database. This option is never essential, sinceclusterdbwill automatically prompt for a password if the server demands password authentication. However,clusterdbwill 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. π--maintenance-db=dbnameβ when-a/--allis used, connect to this database to gather the list of databases to cluster. 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. π§°
π¦ ENVIRONMENT π¦
PGDATABASE,PGHOST,PGPORT,PGUSERβ default connection parameters. β¨PG_COLORβ specifies whether to use color in diagnostic messages. Possible values arealways,autoandnever. π
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15). π«Ά
π₯ DIAGNOSTICS π₯
If things get messy, see CLUSTER(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. π
π EXAMPLES π
To cluster the database test:
$ clusterdb test
To cluster a single table foo in a database named xyzzy:
$ clusterdb --table=foo xyzzy
π SEE ALSO π
CLUSTER(7) β go read it, bestie. Itβs the main character of this whole cluster situation. π«Ά
mwah π β this iconic manual page comes from PostgreSQL 15.19, dated 2026, and thatβs the clusterdb(1) sign-off. Slay responsibly. π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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