Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/ref/clusterdb.sgml`
655d7d067f071e2d64352f6781d386a01a0c865a9bbdfe0e0000000100000fa8
<!--
doc/src/sgml/ref/clusterdb.sgml
PostgreSQL documentation
-->

<refentry id="app-clusterdb">
 <indexterm zone="app-clusterdb">
  <primary>clusterdb</primary>
 </indexterm>

 <refmeta>
  <refentrytitle><application>clusterdb</application></refentrytitle>
  <manvolnum>1</manvolnum>
  <refmiscinfo>Application</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>clusterdb</refname>
  <refpurpose>cluster a <productname>PostgreSQL</productname> database</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
  <cmdsynopsis>
   <command>clusterdb</command>
   <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
   <arg rep="repeat"><replaceable>option</replaceable></arg>

   <arg choice="plain" rep="repeat">
     <arg choice="opt">
       <group choice="plain">
         <arg choice="plain"><option>--table</option></arg>
         <arg choice="plain"><option>-t</option></arg>
       </group>
       <replaceable>table</replaceable>
     </arg>
   </arg>

   <arg choice="opt">
    <group choice="plain">
     <arg choice="plain"><replaceable>dbname</replaceable></arg>
     <arg choice="plain"><option>-a</option></arg>
     <arg choice="plain"><option>--all</option></arg>
    </group>
   </arg>
  </cmdsynopsis>
 </refsynopsisdiv>


 <refsect1>
  <title>Description</title>

  <para>
   <application>clusterdb</application> is a utility for reclustering tables
   in a <productname>PostgreSQL</productname> 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.
  </para>

  <para>
   <application>clusterdb</application> is a wrapper around the SQL
   command <xref linkend="sql-cluster"/>.
   There is no effective difference between clustering databases via
   this utility and via other methods for accessing the server.
  </para>

 </refsect1>


 <refsect1>
  <title>Options</title>

   <para>
    <application>clusterdb</application> accepts the following command-line arguments:

    <variablelist>
     <varlistentry>
      <term><option>-a</option></term>
      <term><option>--all</option></term>
      <listitem>
       <para>
        Cluster all databases.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option><optional>-d</optional> <replaceable class="parameter">dbname</replaceable></option></term>
      <term><option><optional>--dbname=</optional><replaceable class="parameter">dbname</replaceable></option></term>
      <listitem>
       <para>
        Specifies the name of the database to be clustered,
        when <option>-a</option>/<option>--all</option> is not used.
        If this is not specified, the database name is read
        from the environment variable <envar>PGDATABASE</envar>.  If
        that is not set, the user name specified for the connection is
        used.  The <replaceable>dbname</replaceable> can be a <link
        linkend="libpq-connstring">connection string</link>.  If so,
        connection string parameters will override any conflicting command
        line options.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-e</option></term>
      <term><option>--echo</option></term>
      <listitem>
       <para>
        Echo the commands that <application>clusterdb</application> generates
        and sends to the server.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-q</option></term>
      <term><option>--quiet</option></term>
      <listitem>
       <para>
        Do not display progress messages.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-t <replaceable class="parameter">table</replaceable></option></term>
      <term><option>--table=<replaceable class="parameter">table</replaceable></option></term>
      <listitem>
       <para>
        Cluster <replaceable class="parameter">table</replaceable>

Title: clusterdb: Reclustering PostgreSQL Databases
Summary
The `clusterdb` utility re-clusters tables in a PostgreSQL database, using the same index as the last clustering operation. It essentially wraps the SQL command `CLUSTER`. Options include clustering all databases, specifying a database name, echoing commands, suppressing progress messages, and specifying individual tables to cluster.