CLUSTERDB(1)
π clusterdb(1) β the group-chat guide
Okay bestie, so the manual name is clusterdb and it lives in section 1 of the PostgreSQL 14.24 docs, and honestly? She's iconic, she's lowkey underrated, and we're gonna get through her together. π«Ά
β¨ NAME β¨
clusterdb β cluster a PostgreSQL database π₯
πΈ SYNOPSIS πΈ
clusterdb [connection-option...] [--verbose | -v]
[ --table | -t table ]... [dbname]
clusterdb [connection-option...] [--verbose | -v] --all | -a
π¦ DESCRIPTION π¦
So clusterdb is a utility for reclustering tables in a PostgreSQL database. And the way it works is genuinely so cute: it goes and finds the tables that have previously been clustered, and then it clusters them again on the same index that was last used. Periodt. π
Tables that have never been clustered? Not affected. She leaves them alone, no notes. π
clusterdb is a wrapper around the SQL command CLUSTER(7). And ngl, there is no effective difference between clustering databases via this utility and via other methods for accessing the server β it's the same slay either way. β¨
π OPTIONS π
clusterdb accepts the following command-line arguments:
-a,--allβ Cluster all databases. all of them. every last one. π[-d] dbname,[--dbname=]dbnameβ Specifies the name of the database to be clustered, 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. Also, heads up: the dbname can be a connection string β and if so, connection string parameters will override any conflicting command line options. ikyk π-e,--echoβ Echo the commands thatclusterdbgenerates and sends to the server. Like a little receipt of everything she did. π§Ύ-q,--quietβ Do not display progress messages. shhh. π€«-t table,--table=tableβ Cluster table only. Multiple tables can be clustered by writing multiple-tswitches β just keep stacking them, she can handle it. π-v,--verboseβ Print detailed information during processing. give us the lore. π-V,--versionβ Print theclusterdbversion and exit. bye bestie π-?,--helpβ Show help aboutclusterdbcommand line arguments, and exit. extremely helpful energy. π
clusterdb 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. Oh and if the value begins with a slash, it is used as the directory for the Unix domain socket. character development tbh π¦-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. who are you today π-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. no cap, it's giving automation π₯²-W,--passwordβ Forceclusterdbto prompt for a password before connecting to a database.
This option is never essential, since clusterdb will automatically prompt for a password if the server demands password authentication. However, clusterdb 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. efficiency queen β¨
--maintenance-db=dbnameβ When the-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. the way she recycles ππ«Ά
π ENVIRONMENT π
PGDATABASEPGHOSTPGPORTPGUSER
Default connection parameters π
PG_COLORβ Specifies whether to use color in diagnostic messages. Possible values arealways,autoandnever. yes we're doing color diagnostics, we love a served look π
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15). standard behavior, fr fr. π
π DIAGNOSTICS π
In case of difficulty, 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. like, please make sure the server is actually up before you come for her π
β EXAMPLES β
To cluster the database test:
$ clusterdb test
To cluster a single table foo in a database named xyzzy:
$ clusterdb --table=foo xyzzy
look at her go π₯Ήβ¨
π§ SEE ALSO π§
Okay that's the whole page bestie, you ate that ππ β this was PostgreSQL 14.24, dated 2026, and she's filed under CLUSTERDB(1). go cluster something. periodt. π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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