1CLUSTERDB(1) PostgreSQL 13.3 Documentation CLUSTERDB(1)
2
3
4
6 clusterdb - cluster a PostgreSQL database
7
9 clusterdb [connection-option...] [--verbose | -v]
10 [ --table | -t table ]... [dbname]
11
12 clusterdb [connection-option...] [--verbose | -v] --all | -a
13
15 clusterdb is a utility for reclustering tables in a PostgreSQL
16 database. It finds tables that have previously been clustered, and
17 clusters them again on the same index that was last used. Tables that
18 have never been clustered are not affected.
19
20 clusterdb is a wrapper around the SQL command CLUSTER(7). There is no
21 effective difference between clustering databases via this utility and
22 via other methods for accessing the server.
23
25 clusterdb accepts the following command-line arguments:
26
27 -a
28 --all
29 Cluster all databases.
30
31 [-d] dbname
32 [--dbname=]dbname
33 Specifies the name of the database to be clustered, when -a/--all
34 is not used. If this is not specified, the database name is read
35 from the environment variable PGDATABASE. If that is not set, the
36 user name specified for the connection is used. The dbname can be a
37 connection string. If so, connection string parameters will
38 override any conflicting command line options.
39
40 -e
41 --echo
42 Echo the commands that clusterdb generates and sends to the server.
43
44 -q
45 --quiet
46 Do not display progress messages.
47
48 -t table
49 --table=table
50 Cluster table only. Multiple tables can be clustered by writing
51 multiple -t switches.
52
53 -v
54 --verbose
55 Print detailed information during processing.
56
57 -V
58 --version
59 Print the clusterdb version and exit.
60
61 -?
62 --help
63 Show help about clusterdb command line arguments, and exit.
64
65 clusterdb also accepts the following command-line arguments for
66 connection parameters:
67
68 -h host
69 --host=host
70 Specifies the host name of the machine on which the server is
71 running. If the value begins with a slash, it is used as the
72 directory for the Unix domain socket.
73
74 -p port
75 --port=port
76 Specifies the TCP port or local Unix domain socket file extension
77 on which the server is listening for connections.
78
79 -U username
80 --username=username
81 User name to connect as.
82
83 -w
84 --no-password
85 Never issue a password prompt. If the server requires password
86 authentication and a password is not available by other means such
87 as a .pgpass file, the connection attempt will fail. This option
88 can be useful in batch jobs and scripts where no user is present to
89 enter a password.
90
91 -W
92 --password
93 Force clusterdb to prompt for a password before connecting to a
94 database.
95
96 This option is never essential, since clusterdb will automatically
97 prompt for a password if the server demands password
98 authentication. However, clusterdb will waste a connection attempt
99 finding out that the server wants a password. In some cases it is
100 worth typing -W to avoid the extra connection attempt.
101
102 --maintenance-db=dbname
103 Specifies the name of the database to connect to to discover which
104 databases should be clustered, when -a/--all is used. If not
105 specified, the postgres database will be used, or if that does not
106 exist, template1 will be used. This can be a connection string. If
107 so, connection string parameters will override any conflicting
108 command line options. Also, connection string parameters other than
109 the database name itself will be re-used when connecting to other
110 databases.
111
113 PGDATABASE
114 PGHOST
115 PGPORT
116 PGUSER
117 Default connection parameters
118
119 PG_COLOR
120 Specifies whether to use color in diagnostic messages. Possible
121 values are always, auto and never.
122
123 This utility, like most other PostgreSQL utilities, also uses the
124 environment variables supported by libpq (see Section 33.14).
125
127 In case of difficulty, see CLUSTER(7) and psql(1) for discussions of
128 potential problems and error messages. The database server must be
129 running at the targeted host. Also, any default connection settings and
130 environment variables used by the libpq front-end library will apply.
131
133 To cluster the database test:
134
135 $ clusterdb test
136
137 To cluster a single table foo in a database named xyzzy:
138
139 $ clusterdb --table=foo xyzzy
140
142 CLUSTER(7)
143
144
145
146PostgreSQL 13.3 2021 CLUSTERDB(1)