See also <ahref="#options">options</a> for details.</p>
<dl>
<dt>connection-options</dt>
<dd>-h [--host] host</dd>
<dd>-p [--port] port</dd>
<dd>-U [--username] username</dd>
<dd>-W [--password]</dd>
<dt>message-options</dt>
<dd>-q [--quiet]</dd>
<dd>-v [--verbose]</dd>
<dt>order-options</dt>
<dd>-o [--order-by] columns [,...]</dd>
<dd>-n [--no-order]</dd>
<dt>target-options</dt>
<dd>-a [--all]</dd>
<dd>-d [--dbname] dbname</dd>
<dd>-t [--table] table</dd>
<dd>-Z [--no-analyze]</dd>
</dl>
<h2id="description">Description</h2>
<p>pg_reorg is an utility program to reorganize tables in PostgreSQL databases.
Unlike <ahref="http://www.postgresql.jp/document/current/html/app-clusterdb.html">clusterdb</a>, it doesn't block any selections and updates during reorganization.
You can choose one of the following methods to reorganize.</p>
<ul>
<li>Online CLUSTER (ordered by cluster index)</li>
<li>Ordered by specified columns</li>
<li>Online VACUUM FULL (packing rows only)</li>
</ul>
<p>NOTICE:</p>
<ul>
<li>Only superusers can use the utility.</li>
<li>Target table must have PRIMARY KEY.</li>
</ul>
<h2id="examples">Examples</h2>
<p>Execute the following command to do online CLUSTER to all tables in test database.</p>
<p>pg_reorg has command line options in 4 categolies.</p>
<div>
<dl>
<h3>connection-options</h3>
<p>Parameters to connect PostgreSQL.</p>
<div>
<dl>
<dt>-h host<br/>
--host host</dt>
<dd>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. </dd>
<dt>-p port<br/>
--port port</dt>
<dd>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.</dd>
<dt>-U username<br/>
--username username</dt>
<dd>User name to connect as. </dd>
<dt>-W<br/>--password</dt>
<dd>Force pg_reorg to prompt for a password before connecting to a database.</dd>
<dd>This option is never essential, since pg_reorg will automatically prompt for a password if the server demands password authentication. However, vacuumdb will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. </dd>
</dl>
<h3>message-options</h3>
<p>Specifies message output by pg_reorg.
--quiet is ignored if some of the other options are specified.</p>
<dl>
<dt>-q<br/>--quiet</dt>
<dd>Do not display progress messages. </dd>
<dt>-v<br/>--verbose</dt>
<dd>Print detailed information during processing.</dd>
</dl>
<h3>order-options</h3>
<p>Options to order rows.
If not specified, pg_reorg do online CLUSTER using cluster indexes.
Only one option can be specified.
</p>
<dl>
<dt>-n<br/>--no-order</dt>
<dd>Do online VACUUM FULL.</dd>
<dt>-o columns [,...]<br/>
--order-by columns [,...]</dt>
<dd>Do online CLUSTER ordered by specified columns.</dd>
</dl>
<h3>target-options</h3>
<p>
Options to specify target tables or databases.
You cannot use --all and --dbname or --table together.
</p>
<dl>
<dt>-a<br/>--all</dt>
<dd>Reorganize all databases.</dd>
<dt>
-d dbname<br/>
--dbname dbname
</dt>
<dd>Specifies the name of the database to be reorganized. If this is not specified and -a (or --all) is not used, the database name is read from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is used. </dd>
<dt>
-t table<br/>
--table table
</dt>
<dd>Reorganize table only. If you don't specify this option, all tables in specified databases are reorganized.</dd>
<dt>-Z<br/>--no-analyze</dt>
<dd>Do ANALYZE after reorganization. If you don't specify this option, ANALYZE is performed automatically after reorg.</dd>
</dl>
<h2id="environment">Environment</h2>
<dl>
<dt>
PGDATABASE<br/>
PGHOST<br/>
PGPORT<br/>
PGUSER
</dt>
<dd>Default connection parameters</dd>
</dl>
<p>This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see <ahref="http://developer.postgresql.org/pgdocs/postgres/libpq-envars.html">Environment Variables</a>).</p>
<h2id="diagnostics">Diagnostics</h2>
<p>Error messages are reported when pg_reorg fails.
The following list shows the cause of errors.</p>
<p>You need to cleanup by hand after fatal erros.
To cleanup, execute $PGHOME/share/contrib/uninstall_pg_reorg.sql to the database where the error occured and then execute $PGHOME/share/contrib/pg_reorg.sql. (Do uninstall and reinstall.)</p>