<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.45 2009/11/27 17:41:26 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.46 2010/01/06 02:59:44 momjian Exp $
PostgreSQL documentation
-->
<command>vacuumdb</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<group><arg>--full</arg><arg>-f</arg></group>
+ <group><arg>--freeze</arg><arg>-F</arg></group>
<group><arg>--verbose</arg><arg>-v</arg></group>
<group><arg>--analyze</arg><arg>-z</arg></group>
- <group><arg>--freeze</arg><arg>-F</arg></group>
+ <group><arg>--only-analyze</arg><arg>-o</arg></group>
<arg>--table | -t <replaceable>table</replaceable>
<arg>( <replaceable class="parameter">column</replaceable> [,...] )</arg>
</arg>
<arg rep="repeat"><replaceable>connection-options</replaceable></arg>
<group><arg>--all</arg><arg>-a</arg></group>
<group><arg>--full</arg><arg>-f</arg></group>
+ <group><arg>--freeze</arg><arg>-F</arg></group>
<group><arg>--verbose</arg><arg>-v</arg></group>
<group><arg>--analyze</arg><arg>-z</arg></group>
- <group><arg>--freeze</arg><arg>-F</arg></group>
+ <group><arg>--only-analyze</arg><arg>-o</arg></group>
</cmdsynopsis>
</refsynopsisdiv>
<para>
<application>vacuumdb</application> is a wrapper around the SQL
command <xref linkend="SQL-VACUUM" endterm="SQL-VACUUM-title">.
- There is no effective difference between vacuuming databases via
- this utility and via other methods for accessing the server.
+ There is no effective difference between vacuuming and analyzing
+ databases via this utility and via other methods for accessing the
+ server.
</para>
</refsect1>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-F</option></term>
+ <term><option>--freeze</option></term>
+ <listitem>
+ <para>
+ Aggressively <quote>freeze</quote> tuples.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-o</option></term>
+ <term><option>--only-analyze</option></term>
+ <listitem>
+ <para>
+ Only calculate statistics for use by the optimizer (no vacuum).
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>-q</></term>
<term><option>--quiet</></term>
<para>
Clean or analyze <replaceable class="parameter">table</replaceable> only.
Column names can be specified only in conjunction with
- the <option>--analyze</option> option.
+ the <option>--analyze</option> or <option>--only-analyze</option> options.
</para>
<tip>
<para>
</listitem>
</varlistentry>
- <varlistentry>
- <term><option>-F</option></term>
- <term><option>--freeze</option></term>
- <listitem>
- <para>
- Aggressively <quote>freeze</quote> tuples.
- </para>
- </listitem>
- </varlistentry>
</variablelist>
</para>
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.28 2010/01/02 16:58:00 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.29 2010/01/06 02:59:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "common.h"
-static void vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze,
- bool freeze, const char *table,
- const char *host, const char *port,
+static void vacuum_one_database(const char *dbname, bool full, bool verbose,
+ bool and_analyze, bool only_analyze, bool freeze,
+ const char *table, const char *host, const char *port,
const char *username, enum trivalue prompt_password,
const char *progname, bool echo);
-static void vacuum_all_databases(bool full, bool verbose, bool analyze, bool freeze,
+static void vacuum_all_databases(bool full, bool verbose, bool and_analyze,
+ bool only_analyze, bool freeze,
const char *host, const char *port,
const char *username, enum trivalue prompt_password,
const char *progname, bool echo, bool quiet);
{"quiet", no_argument, NULL, 'q'},
{"dbname", required_argument, NULL, 'd'},
{"analyze", no_argument, NULL, 'z'},
+ {"only-analyze", no_argument, NULL, 'o'},
{"freeze", no_argument, NULL, 'F'},
{"all", no_argument, NULL, 'a'},
{"table", required_argument, NULL, 't'},
enum trivalue prompt_password = TRI_DEFAULT;
bool echo = false;
bool quiet = false;
- bool analyze = false;
+ bool and_analyze = false;
+ bool only_analyze = false;
bool freeze = false;
bool alldb = false;
char *table = NULL;
dbname = optarg;
break;
case 'z':
- analyze = true;
+ and_analyze = true;
+ break;
+ case 'o':
+ only_analyze = true;
break;
case 'F':
freeze = true;
setup_cancel_handler();
+ if (only_analyze)
+ {
+ if (full)
+ {
+ fprintf(stderr, _("%s: cannot use the \"full\" option when performing only analyze\n"),
+ progname);
+ exit(1);
+ }
+ if (freeze)
+ {
+ fprintf(stderr, _("%s: cannot use the \"freeze\" option when performing only analyze\n"),
+ progname);
+ exit(1);
+ }
+ /* ignore 'and_analyze' */
+ }
+
if (alldb)
{
if (dbname)
exit(1);
}
- vacuum_all_databases(full, verbose, analyze, freeze,
+ vacuum_all_databases(full, verbose, and_analyze, only_analyze, freeze,
host, port, username, prompt_password,
progname, echo, quiet);
}
dbname = get_user_name(progname);
}
- vacuum_one_database(dbname, full, verbose, analyze, freeze, table,
+ vacuum_one_database(dbname, full, verbose, and_analyze, only_analyze,
+ freeze, table,
host, port, username, prompt_password,
progname, echo);
}
static void
-vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze,
- bool freeze, const char *table,
+vacuum_one_database(const char *dbname, bool full, bool verbose, bool and_analyze,
+ bool only_analyze, bool freeze, const char *table,
const char *host, const char *port,
const char *username, enum trivalue prompt_password,
const char *progname, bool echo)
initPQExpBuffer(&sql);
- appendPQExpBuffer(&sql, "VACUUM");
- if (full)
- appendPQExpBuffer(&sql, " FULL");
- if (freeze)
- appendPQExpBuffer(&sql, " FREEZE");
+ if (only_analyze)
+ appendPQExpBuffer(&sql, "ANALYZE");
+ else
+ {
+ appendPQExpBuffer(&sql, "VACUUM");
+ if (full)
+ appendPQExpBuffer(&sql, " FULL");
+ if (freeze)
+ appendPQExpBuffer(&sql, " FREEZE");
+ if (and_analyze)
+ appendPQExpBuffer(&sql, " ANALYZE");
+ }
if (verbose)
appendPQExpBuffer(&sql, " VERBOSE");
- if (analyze)
- appendPQExpBuffer(&sql, " ANALYZE");
if (table)
appendPQExpBuffer(&sql, " %s", table);
appendPQExpBuffer(&sql, ";\n");
static void
-vacuum_all_databases(bool full, bool verbose, bool analyze, bool freeze,
- const char *host, const char *port,
+vacuum_all_databases(bool full, bool verbose, bool and_analyze, bool only_analyze,
+ bool freeze, const char *host, const char *port,
const char *username, enum trivalue prompt_password,
const char *progname, bool echo, bool quiet)
{
fflush(stdout);
}
- vacuum_one_database(dbname, full, verbose, analyze, freeze, NULL,
- host, port, username, prompt_password,
+ vacuum_one_database(dbname, full, verbose, and_analyze, only_analyze,
+ freeze, NULL, host, port, username, prompt_password,
progname, echo);
}
printf(_(" -e, --echo show the commands being sent to the server\n"));
printf(_(" -f, --full do full vacuuming\n"));
printf(_(" -F, --freeze freeze row transaction information\n"));
+ printf(_(" -o, --only-analyze only update optimizer hints\n"));
printf(_(" -q, --quiet don't write any messages\n"));
printf(_(" -t, --table='TABLE[(COLUMNS)]' vacuum specific table only\n"));
printf(_(" -v, --verbose write a lot of output\n"));