Linux "clusterdb" Command Line Options and Examples
cluster a PostgreSQL database

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.


Usage:

clusterdb [connection-option...] [--verbose | -v] [ --table | -t table ]... [dbname]


    clusterdb [connection-option...] [--verbose | -v] --all | -a




Command Line Options:

--all
Cluster all databases.
clusterdb --all ...
--dbname
Specifies the name of the database to be clustered. If this is not specified and -a (or --all) is not used, the database name isread from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is used.
clusterdb --dbname ...
--echo
Echo the commands that clusterdb generates and sends to the server.
clusterdb --echo ...
--quiet
Do not display progress messages.
clusterdb --quiet ...
--table
Cluster table only. Multiple tables can be clustered by writing multiple -t switches.
clusterdb --table ...
--verbose
Print detailed information during processing.
clusterdb --verbose ...
--version
Print the clusterdb version and exit.
clusterdb --version ...
--help
Show help about clusterdb command line arguments, and exit.clusterdb also accepts the following command-line arguments for connection parameters:
clusterdb --help ...
--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 thedirectory for the Unix domain socket.
clusterdb --host ...
--port
Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.
clusterdb --port ...
--username
User name to connect as.
clusterdb --username ...
--no-password
Never issue a password prompt. If the server requires password authentication and a password is not available by other means suchas a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is presentto enter a password.
clusterdb --no-password ...
--password
Force clusterdb to 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 passwordauthentication. However, clusterdb will waste a connection attempt finding out that the server wants a password. In some cases itis worth typing -W to avoid the extra connection attempt.
clusterdb --password ...
--maintenance-db
Specifies the name of the database to connect to discover what other databases should be clustered. If not specified, thepostgres database will be used, and if that does not exist, template1 will be used.ENVIRONMENTPGDATABASEPGHOSTPGPORTPGUSERDefault connection parametersThis utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 33.14).DIAGNOSTICSIn case of difficulty, see CLUSTER(7) and psql(1) for discussions of potential problems and error messages. The database server mustbe running at the targeted host. Also, any default connection settings and environment variables used by the libpq front-end librarywill apply.EXAMPLESTo cluster the database test:$ clusterdb testTo cluster a single table foo in a database named xyzzy:$ clusterdb --table=foo xyzzy
clusterdb --maintenance-db ...