Reclusters tables that were previously clustered with CLUSTER
.
clusterdb [<connection-option> ...] [--verbose | -v] [--table | -t <table>] [[--dbname | -d] <dbname]
clusterdb [<connection-option> ...] [--verbose | -v] --all | -a
clusterdb -? | --help
clusterdb -V | --version
To cluster a table means to physically reorder a table on disk according to an index. Clustering helps improving index seek performance for queries that use that index. Clustering is a one-time operation: when the table is subsequently updated, the changes are not clustered. That is, no attempt is made to store new or updated rows according to their index order.
The clusterdb
utility will find any tables in a database that have previously been clustered with the CLUSTER
SQL command, and clusters them again on the same index that was last used. Tables that have never been clustered are not affected.
clusterdb
is a wrapper around the SQL command CLUSTER. There is no effective difference between clustering databases via this utility and via other methods for accessing the server.
clusterdb
accepts the following command-line arguments:
-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.
clusterdb
generates and sends to the server.
-t
switches.
clusterdb
version, and exit.
clusterdb
command line arguments, and exit.
Connection Options
clusterdb
also accepts the following command-line arguments for connection parameters:
PGHOST
or defaults to
localhost
.
PGPORT
or defaults to 5432.
PGUSER
or defaults to the current system role name.
.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.
clusterdb
to prompt for a password before connecting to a database.
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.
postgres
database will be used, and 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.
always
,
auto
, and
never
.
This utility, like most other Greenplum Database utilities, also uses the environment variables supported by libpq
.
In case of difficulty, see CLUSTER and psql 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.
To cluster the database named test
:
clusterdb test
To cluster a single table foo
in a database named xyzzy
:
clusterdb --table=foo xyzzy