2 doc/src/sgml/ref/clusterdb.sgml
3 PostgreSQL documentation
6 <refentry id=
"app-clusterdb">
7 <indexterm zone=
"app-clusterdb">
8 <primary>clusterdb
</primary>
12 <refentrytitle><application>clusterdb
</application></refentrytitle>
13 <manvolnum>1</manvolnum>
14 <refmiscinfo>Application
</refmiscinfo>
18 <refname>clusterdb
</refname>
19 <refpurpose>cluster a
<productname>PostgreSQL
</productname> database
</refpurpose>
24 <command>clusterdb
</command>
25 <arg rep=
"repeat"><replaceable>connection-option
</replaceable></arg>
26 <arg rep=
"repeat"><replaceable>option
</replaceable></arg>
28 <arg choice=
"plain" rep=
"repeat">
30 <group choice=
"plain">
31 <arg choice=
"plain"><option>--table
</option></arg>
32 <arg choice=
"plain"><option>-t
</option></arg>
34 <replaceable>table
</replaceable>
39 <group choice=
"plain">
40 <arg choice=
"plain"><replaceable>dbname
</replaceable></arg>
41 <arg choice=
"plain"><option>-a
</option></arg>
42 <arg choice=
"plain"><option>--all
</option></arg>
50 <title>Description
</title>
53 <application>clusterdb
</application> is a utility for reclustering tables
54 in a
<productname>PostgreSQL
</productname> database. It finds tables
55 that have previously been clustered, and clusters them again on the same
56 index that was last used. Tables that have never been clustered are not
61 <application>clusterdb
</application> is a wrapper around the SQL
62 command
<xref linkend=
"sql-cluster"/>.
63 There is no effective difference between clustering databases via
64 this utility and via other methods for accessing the server.
71 <title>Options
</title>
74 <application>clusterdb
</application> accepts the following command-line arguments:
78 <term><option>-a
</option></term>
79 <term><option>--all
</option></term>
82 Cluster all databases.
88 <term><option><optional>-d
</optional> <replaceable class=
"parameter">dbname
</replaceable></option></term>
89 <term><option><optional>--dbname=
</optional><replaceable class=
"parameter">dbname
</replaceable></option></term>
92 Specifies the name of the database to be clustered,
93 when
<option>-a
</option>/
<option>--all
</option> is not used.
94 If this is not specified, the database name is read
95 from the environment variable
<envar>PGDATABASE
</envar>. If
96 that is not set, the user name specified for the connection is
97 used. The
<replaceable>dbname
</replaceable> can be a
<link
98 linkend=
"libpq-connstring">connection string
</link>. If so,
99 connection string parameters will override any conflicting command
106 <term><option>-e
</option></term>
107 <term><option>--echo
</option></term>
110 Echo the commands that
<application>clusterdb
</application> generates
111 and sends to the server.
117 <term><option>-q
</option></term>
118 <term><option>--quiet
</option></term>
121 Do not display progress messages.
127 <term><option>-t
<replaceable class=
"parameter">table
</replaceable></option></term>
128 <term><option>--table=
<replaceable class=
"parameter">table
</replaceable></option></term>
131 Cluster
<replaceable class=
"parameter">table
</replaceable> only.
132 Multiple tables can be clustered by writing multiple
133 <option>-t
</option> switches.
139 <term><option>-v
</option></term>
140 <term><option>--verbose
</option></term>
143 Print detailed information during processing.
149 <term><option>-V
</option></term>
150 <term><option>--version
</option></term>
153 Print the
<application>clusterdb
</application> version and exit.
159 <term><option>-?
</option></term>
160 <term><option>--help
</option></term>
163 Show help about
<application>clusterdb
</application> command line
173 <application>clusterdb
</application> also accepts
174 the following command-line arguments for connection parameters:
178 <term><option>-h
<replaceable class=
"parameter">host
</replaceable></option></term>
179 <term><option>--host=
<replaceable class=
"parameter">host
</replaceable></option></term>
182 Specifies the host name of the machine on which the server is
183 running. If the value begins with a slash, it is used as the
184 directory for the Unix domain socket.
190 <term><option>-p
<replaceable class=
"parameter">port
</replaceable></option></term>
191 <term><option>--port=
<replaceable class=
"parameter">port
</replaceable></option></term>
194 Specifies the TCP port or local Unix domain socket file
195 extension on which the server
196 is listening for connections.
202 <term><option>-U
<replaceable class=
"parameter">username
</replaceable></option></term>
203 <term><option>--username=
<replaceable class=
"parameter">username
</replaceable></option></term>
206 User name to connect as.
212 <term><option>-w
</option></term>
213 <term><option>--no-password
</option></term>
216 Never issue a password prompt. If the server requires
217 password authentication and a password is not available by
218 other means such as a
<filename>.pgpass
</filename> file, the
219 connection attempt will fail. This option can be useful in
220 batch jobs and scripts where no user is present to enter a
227 <term><option>-W
</option></term>
228 <term><option>--password
</option></term>
231 Force
<application>clusterdb
</application> to prompt for a
232 password before connecting to a database.
236 This option is never essential, since
237 <application>clusterdb
</application> will automatically prompt
238 for a password if the server demands password authentication.
239 However,
<application>clusterdb
</application> will waste a
240 connection attempt finding out that the server wants a password.
241 In some cases it is worth typing
<option>-W
</option> to avoid the extra
248 <term><option>--maintenance-db=
<replaceable class=
"parameter">dbname
</replaceable></option></term>
251 Specifies the name of the database to connect to to discover which
252 databases should be clustered,
253 when
<option>-a
</option>/
<option>--all
</option> is used.
254 If not specified, the
<literal>postgres
</literal> database will be used,
255 or if that does not exist,
<literal>template1
</literal> will be used.
256 This can be a
<link linkend=
"libpq-connstring">connection
257 string
</link>. If so, connection string parameters will override any
258 conflicting command line options. Also, connection string parameters
259 other than the database name itself will be re-used when connecting
270 <title>Environment
</title>
274 <term><envar>PGDATABASE
</envar></term>
275 <term><envar>PGHOST
</envar></term>
276 <term><envar>PGPORT
</envar></term>
277 <term><envar>PGUSER
</envar></term>
281 Default connection parameters
287 <term><envar>PG_COLOR
</envar></term>
290 Specifies whether to use color in diagnostic messages. Possible values
291 are
<literal>always
</literal>,
<literal>auto
</literal> and
292 <literal>never
</literal>.
299 This utility, like most other
<productname>PostgreSQL
</productname> utilities,
300 also uses the environment variables supported by
<application>libpq
</application>
301 (see
<xref linkend=
"libpq-envars"/>).
308 <title>Diagnostics
</title>
311 In case of difficulty, see
<xref linkend=
"sql-cluster"/>
312 and
<xref linkend=
"app-psql"/> for
313 discussions of potential problems and error messages.
314 The database server must be running at the
315 targeted host. Also, any default connection settings and environment
316 variables used by the
<application>libpq
</application> front-end
324 <title>Examples
</title>
327 To cluster the database
<literal>test
</literal>:
329 <prompt>$
</prompt><userinput>clusterdb test
</userinput>
334 To cluster a single table
335 <literal>foo
</literal> in a database named
336 <literal>xyzzy
</literal>:
338 <prompt>$
</prompt><userinput>clusterdb --table=foo xyzzy
</userinput>
344 <title>See Also
</title>
346 <simplelist type=
"inline">
347 <member><xref linkend=
"sql-cluster"/></member>