3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "CLUSTERDB" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 clusterdb \- cluster a PostgreSQL database
33 .HP \w'\fBclusterdb\fR\ 'u
34 \fBclusterdb\fR [\fIconnection\-option\fR...] [\fIoption\fR...] [\ \fB\-\-table\fR\ |\ \fB\-t\fR\ \fItable\fR\ ]... [\fIdbname\fR\ |\ \fB\-a\fR\ |\ \fB\-\-all\fR]
38 is a utility for reclustering tables in a
40 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\&.
43 is a wrapper around the SQL command
44 \fBCLUSTER\fR(7)\&. There is no effective difference between clustering databases via this utility and via other methods for accessing the server\&.
48 accepts the following command\-line arguments:
54 Cluster all databases\&.
57 \fB[\-d]\fR\fB \fR\fB\fIdbname\fR\fR
59 \fB[\-\-dbname=]\fR\fB\fIdbname\fR\fR
61 Specifies the name of the database to be clustered, when
62 \fB\-a\fR/\fB\-\-all\fR
63 is not used\&. If this is not specified, the database name is read from the environment variable
64 \fBPGDATABASE\fR\&. If that is not set, the user name specified for the connection is used\&. The
67 connection string\&. If so, connection string parameters will override any conflicting command line options\&.
74 Echo the commands that
76 generates and sends to the server\&.
83 Do not display progress messages\&.
86 \fB\-t \fR\fB\fItable\fR\fR
88 \fB\-\-table=\fR\fB\fItable\fR\fR
92 only\&. Multiple tables can be clustered by writing multiple
101 Print detailed information during processing\&.
119 command line arguments, and exit\&.
123 also accepts the following command\-line arguments for connection parameters:
125 \fB\-h \fR\fB\fIhost\fR\fR
127 \fB\-\-host=\fR\fB\fIhost\fR\fR
129 Specifies the host name of the machine on which the server is running\&. If the value begins with a slash, it is used as the directory for the Unix domain socket\&.
132 \fB\-p \fR\fB\fIport\fR\fR
134 \fB\-\-port=\fR\fB\fIport\fR\fR
136 Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections\&.
139 \fB\-U \fR\fB\fIusername\fR\fR
141 \fB\-\-username=\fR\fB\fIusername\fR\fR
143 User name to connect as\&.
148 \fB\-\-no\-password\fR
150 Never issue a password prompt\&. If the server requires password authentication and a password is not available by other means such as a
152 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\&.
161 to prompt for a password before connecting to a database\&.
163 This option is never essential, since
165 will automatically prompt for a password if the server demands password authentication\&. However,
167 will waste a connection attempt finding out that the server wants a password\&. In some cases it is worth typing
169 to avoid the extra connection attempt\&.
172 \fB\-\-maintenance\-db=\fR\fB\fIdbname\fR\fR
175 \fB\-a\fR/\fB\-\-all\fR
176 is used, connect to this database to gather the list of databases to cluster\&. If not specified, the
178 database will be used, or if that does not exist,
180 will be used\&. This can be a
181 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\&.
193 Default connection parameters
198 Specifies whether to use color in diagnostic messages\&. Possible values are
205 This utility, like most other
207 utilities, also uses the environment variables supported by
213 In case of difficulty, see
217 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
219 front\-end library will apply\&.
222 To cluster the database
229 $ \fBclusterdb test\fR
235 To cluster a single table
244 $ \fBclusterdb \-\-table=foo xyzzy\fR