Reclusters tables that were previously clustered with CLUSTER
.
clusterdb [<connection-option> ...] [--verbose | -v] [--table | -t <table>] [[--dbname | -d] <dbname]
clusterdb [<connection-option> ...] [--all | -a] [--verbose | -v]
clusterdb -? | --help
clusterdb -V | --version
To cluster a table means to physically reorder a table on disk according to an index so that index scan operations can access data on disk in a somewhat sequential order, thereby improving index seek performance for queries that use that index.
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
. Although clustering a table in this way is supported in Greenplum Database, it is not recommended because the CLUSTER
operation itself is extremely slow.
If you do need to order a table in this way to improve your query performance, use a CREATE TABLE AS
statement to reorder the table on disk rather than using CLUSTER
. If you do 'cluster' a table in this way, then clusterdb
would not be relevant.
PGDATABASE
. If that is not set, the user name specified for the connection is used.
clusterdb
generates and sends to the server.
-t
switches.
clusterdb
version and exit.
clusterdb
command line arguments, and exit.
Connection Options
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.
postgres
database will be used, and if that does not exist,
template1
will be used.
To cluster the database test
:
clusterdb test
To cluster a single table foo
in a database named xyzzy
:
clusterdb --table foo xyzzyb