バージョンごとのドキュメント一覧

vacuumdb

vacuumdb <refpurpose>garbage-collect and analyze a <productname>PostgreSQL</productname> database</refpurpose> PostgreSQLデータベースの不要領域の回収と解析を行う

概要

vacuumdb [connection-option...] [option...] [ -t | --table table [( column [,...] )] ] ... [dbname]

vacuumdb [connection-option...] [option...] [ [ -n | --schema schema ] | [ -N | --exclude-schema schema ] ] ... [dbname]

vacuumdb [connection-option...] [option...] -a | --all

説明

<title>Description</title>

<application>vacuumdb</application> is a utility for cleaning a <productname>PostgreSQL</productname> database. <application>vacuumdb</application> will also generate internal statistics used by the <productname>PostgreSQL</productname> query optimizer. vacuumdbは、PostgreSQLデータベースの不要領域のクリーンアップを行うユーティリティです。 また、vacuumdbPostgreSQLの問い合わせオプティマイザが使用する内部的な統計情報も生成します。

<application>vacuumdb</application> is a wrapper around the SQL command <link linkend="sql-vacuum"><command>VACUUM</command></link>. There is no effective difference between vacuuming and analyzing databases via this utility and via other methods for accessing the server. vacuumdbは、SQLコマンドVACUUMのラッパーです。 このユーティリティを使っても、これ以外の方法でサーバにアクセスしてバキュームや解析を行っても特に違いは生じません。

オプション

<title>Options</title>

<application>vacuumdb</application> accepts the following command-line arguments: vacuumdbでは、下記のコマンドライン引数を指定できます。

-a
--all

Vacuum all databases. 全てのデータベースに対してバキュームを行います。

--buffer-usage-limit size

Specifies the <glossterm linkend="glossary-buffer-access-strategy">Buffer Access Strategy</glossterm> ring buffer size for a given invocation of <application>vacuumdb</application>. This size is used to calculate the number of shared buffers which will be reused as part of this strategy. See <xref linkend="sql-vacuum"/>. vacuumdbの指定された呼び出しに対してバッファアクセスストラテジリングバッファサイズを指定します。 このサイズは、このストラテジのパートとして再利用される共有バッファの数を計算するために使用されます。 VACUUMを参照してください。

[-d] dbname
[--dbname=]dbname

Specifies the name of the database to be cleaned or analyzed, when <option>-a</option>/<option>&#45;-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. -a(または--all)も指定されていない場合、不要領域のクリーンアップ、または、解析を行うデータベース名を指定します。 データベース名が指定されていない場合は、データベース名は環境変数PGDATABASEから読み取られます。 この変数も設定されていない場合は、接続時に指定したユーザ名が使用されます。 dbname接続文字列に出来ます。その場合、接続文字列パラメータは競合するコマンドラインオプションを上書きします。

--disable-page-skipping

Disable skipping pages based on the contents of the visibility map. 可視性マップの内容に基づいてページを飛ばすことのないようにします。

-e
--echo

Echo the commands that <application>vacuumdb</application> generates and sends to the server. vacuumdbが生成し、サーバに送るコマンドをエコー表示します。

-f
--full

Perform <quote>full</quote> vacuuming. 完全な(full)クリーンアップを行います。

-F
--freeze

Aggressively <quote>freeze</quote> tuples. 積極的にタプルを凍結します。

--force-index-cleanup

Always remove index entries pointing to dead tuples. 無効なタプルを指しているインデックスエントリを常に削除します。

-j njobs
--jobs=njobs

Execute the vacuum or analyze commands in parallel by running <replaceable class="parameter">njobs</replaceable> commands simultaneously. This option may reduce the processing time but it also increases the load on the database server. njobs個のコマンドを同時に実行することで、vacuumまたはanalyzeコマンドを並列で実行します。このオプションは処理時間を短縮することもありますがデータベースサーバの負荷も増加します。

<application>vacuumdb</application> will open <replaceable class="parameter">njobs</replaceable> connections to the database, so make sure your <xref linkend="guc-max-connections"/> setting is high enough to accommodate all connections. vacuumdbはデータベースに対するnjobs個の接続を開くので、max_connectionsの設定が、これらの接続を許容するだけ十分に大きくしてください。

Note that using this mode together with the <option>-f</option> (<literal>FULL</literal>) option might cause deadlock failures if certain system catalogs are processed in parallel. このモードを-fFULL)オプションと一緒に使うと、一部のシステムカタログが並列処理されてデッドロックのエラーを起こす場合があることに注意してください。

--min-mxid-age mxid_age

Only execute the vacuum or analyze commands on tables with a multixact ID age of at least <replaceable class="parameter">mxid_age</replaceable>. This setting is useful for prioritizing tables to process to prevent multixact ID wraparound (see <xref linkend="vacuum-for-multixact-wraparound"/>). マルチトランザクションIDの年代が少なくともmxid_ageであるテーブルに対してのみ、バキュームもしくは解析コマンドを実行します。 この設定は、マルチトランザクションIDの周回を防ぐためテーブルに優先順位を付けて処理するのに有用です(25.1.5.1を参照してください)。

For the purposes of this option, the multixact ID age of a relation is the greatest of the ages of the main relation and its associated <acronym>TOAST</acronym> table, if one exists. Since the commands issued by <application>vacuumdb</application> will also process the <acronym>TOAST</acronym> table for the relation if necessary, it does not need to be considered separately. このオプションの目的のため、リレーションのマルチトランザクションIDの年代は、主であるリレーションの年代と、存在するなら、関連するTOASTテーブルの年代のうち最大のものです。 vacuumdbにより発行されたコマンドも、必要であればリレーションのTOASTテーブルを処理しますので、別々に分けて考える必要はないです。

--min-xid-age xid_age

Only execute the vacuum or analyze commands on tables with a transaction ID age of at least <replaceable class="parameter">xid_age</replaceable>. This setting is useful for prioritizing tables to process to prevent transaction ID wraparound (see <xref linkend="vacuum-for-wraparound"/>). トランザクションIDの年代が少なくともxid_ageであるテーブルに対してのみ、バキュームもしくは解析コマンドを実行します。 この設定は、トランザクションIDの周回を防ぐためテーブルに優先順位を付けて処理するのに有用です(25.1.5を参照してください)。

For the purposes of this option, the transaction ID age of a relation is the greatest of the ages of the main relation and its associated <acronym>TOAST</acronym> table, if one exists. Since the commands issued by <application>vacuumdb</application> will also process the <acronym>TOAST</acronym> table for the relation if necessary, it does not need to be considered separately. このオプションの目的のため、リレーションのトランザクションIDの年代は、主であるリレーションの年代と、存在するなら、関連するTOASTテーブルの年代のうち最大のものです。 vacuumdbにより発行されたコマンドも、必要であればリレーションのTOASTテーブルを処理しますので、別々に分けて考える必要はないです。

-n schema
--schema=schema

Clean or analyze all tables in <replaceable class="parameter">schema</replaceable> only. Multiple schemas can be vacuumed by writing multiple <option>-n</option> switches. schema内のすべてのテーブルのみをクリーンアップまたは解析します。 -nスイッチを複数記述することで複数のスキーマをバキュームできます。

-N schema
--exclude-schema=schema

Do not clean or analyze any tables in <replaceable class="parameter">schema</replaceable>. Multiple schemas can be excluded by writing multiple <option>-N</option> switches. schema内のテーブルをクリーンアップまたは解析しません。 -Nスイッチを複数記述することで複数のスキーマを除外できます。

--no-index-cleanup

Do not remove index entries pointing to dead tuples. 無効なタプルを指しているインデックスエントリを削除しません。

--no-process-main

Skip the main relation. 主リレーションを飛ばします。

--no-process-toast

Skip the TOAST table associated with the table to vacuum, if any. もし存在するなら、バキュームするテーブルに関連するTOASTテーブルを飛ばします。

--no-truncate

Do not truncate empty pages at the end of the table. テーブルの終わりにある空のページを切り詰めません。

-P parallel_workers
--parallel=parallel_workers

Specify the number of parallel workers for <firstterm>parallel vacuum</firstterm>. This allows the vacuum to leverage multiple CPUs to process indexes. See <xref linkend="sql-vacuum"/>. 並列バキュームのためのパラレルワーカーの数を指定します。 これによりバキュームが複数CPUを活用してインデックスを処理できます。 VACUUMを参照してください。

-q
--quiet

Do not display progress messages. 進行メッセージを表示しません。

--skip-locked

Skip relations that cannot be immediately locked for processing. 処理のためにすぐにロックできないリレーションを飛ばします。

-t table [ (column [,...]) ]
--table=table [ (column [,...]) ]

Clean or analyze <replaceable class="parameter">table</replaceable> only. Column names can be specified only in conjunction with the <option>&#45;-analyze</option> or <option>&#45;-analyze-only</option> options. Multiple tables can be vacuumed by writing multiple <option>-t</option> switches. tableのみをクリーンアップ/解析します。 列名は--analyze--analyze-onlyオプションがある場合にのみ設定できます。 複数の-tスイッチを記述することで複数のテーブルをバキュームすることができます。

ヒント

If you specify columns, you probably have to escape the parentheses from the shell. (See examples below.) 列を指定する場合は、シェルから括弧をエスケープする必要があるでしょう (後述の例を参照してください)。

-v
--verbose

Print detailed information during processing. 処理中に詳細な情報を表示します。

-V
--version

Print the <application>vacuumdb</application> version and exit. vacuumdbのバージョンを表示し、終了します。

-z
--analyze

Also calculate statistics for use by the optimizer. オプティマイザが使用する、データベースの統計情報も算出します。

-Z
--analyze-only

Only calculate statistics for use by the optimizer (no vacuum). オプティマイザにより使用される統計情報の計算のみを行います(バキュームを行いません)。

--analyze-in-stages

Only calculate statistics for use by the optimizer (no vacuum), like <option>&#45;-analyze-only</option>. Run three stages of analyze; the first stage uses the lowest possible statistics target (see <xref linkend="guc-default-statistics-target"/>) to produce usable statistics faster, and subsequent stages build the full statistics. --analyze-onlyと同様、オプティマイザにより使用される統計情報の計算のみを行います(バキュームを行いません)。 分析の3つの段階を実行します。 最初の段階では、使用可能な統計情報をより迅速に生成するために最小の統計情報目標値(default_statistics_targetを参照)を使い、後続のステージでは完全な統計情報を構築します。

This option is only useful to analyze a database that currently has no statistics or has wholly incorrect ones, such as if it is newly populated from a restored dump or by <command>pg_upgrade</command>. Be aware that running with this option in a database with existing statistics may cause the query optimizer choices to become transiently worse due to the low statistics targets of the early stages. このオプションは、統計情報を現在持たないデータベースや、完全に誤った統計情報を持つデータベースを解析する場合にのみ有用です。 例えば、リストアされたダンプやpg_upgradeによって新たにデータが生成された場合などです。 統計情報が既にあるデータベースに対してこのオプションで実行すると、初期段階の統計情報目標値が低いため、問い合わせオプティマイザの選択が一時的に悪化する可能性があることに注意してください。

-?
--help

Show help about <application>vacuumdb</application> command line arguments, and exit. vacuumdbのコマンドライン引数の使用方法を表示し、終了します。

<application>vacuumdb</application> also accepts the following command-line arguments for connection parameters: vacuumdbには、以下に記す接続パラメータ用のコマンドライン引数も指定することもできます。

-h host
--host=host

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. サーバが稼働しているマシンのホスト名を指定します。 ホスト名がスラッシュから始まる場合、Unixドメインソケット用のディレクトリとして使用されます。

-p port
--port=port

Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. サーバが接続を監視するTCPポートもしくはUnixドメインソケットファイルの拡張子を指定します。

-U username
--username=username

User name to connect as. 接続するユーザ名を指定します。

-w
--no-password

Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <filename>.pgpass</filename> 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. パスワードの入力を促しません。 サーバがパスワード認証を必要とし、かつ、.pgpassファイルなどの他の方法が利用できない場合、接続試行は失敗します。 バッチジョブやスクリプトなどパスワードを入力するユーザが存在しない場合にこのオプションは有用かもしれません。

-W
--password

Force <application>vacuumdb</application> to prompt for a password before connecting to a database. データベースに接続する前に、vacuumdbは強制的にパスワード入力を促します。

This option is never essential, since <application>vacuumdb</application> will automatically prompt for a password if the server demands password authentication. However, <application>vacuumdb</application> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <option>-W</option> to avoid the extra connection attempt. サーバがパスワード認証を要求する場合vacuumdbは自動的にパスワード入力を促しますので、これが重要になることはありません。 しかし、vacuumdbは、サーバにパスワードが必要かどうかを判断するための接続試行を無駄に行います。 こうした余計な接続試行を防ぐために-Wの入力が有意となる場合もあります。

--maintenance-db=dbname

Specifies the name of the database to connect to to discover which databases should be vacuumed, when <option>-a</option>/<option>&#45;-all</option> is used. If not specified, the <literal>postgres</literal> database will be used, or if that does not exist, <literal>template1</literal> will be used. This can be a <link linkend="libpq-connstring">connection string</link>. 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. -a(または--all)が指定されている時、どのデータベースをバキュームしなければならないかを見つけ出すために接続するデータベースの名前を指定します。 データベース名が指定されていなければpostgresデータベースが使用され、もし存在しなければtemplate1が使用されます。 これは接続文字列に出来ます。 その場合、接続文字列パラメータは競合するコマンドラインオプションを上書きします。 また、データベース名以外の接続文字列パラメータは他のデータベースに接続する時に再利用されます。

環境

<title>Environment</title>
PGDATABASE
PGHOST
PGPORT
PGUSER

Default connection parameters デフォルトの接続パラメータです。

PG_COLOR

Specifies whether to use color in diagnostic messages. Possible values are <literal>always</literal>, <literal>auto</literal> and <literal>never</literal>. 診断メッセージで色を使うかどうかを指定します。 可能な値はalwaysautoneverです。

This utility, like most other <productname>PostgreSQL</productname> utilities, also uses the environment variables supported by <application>libpq</application> (see <xref linkend="libpq-envars"/>). また、このユーティリティは、他のほとんどのPostgreSQLユーティリティと同様、libpqでサポートされる環境変数を使用します(34.15を参照してください)。

診断

<title>Diagnostics</title>

In case of difficulty, see <xref linkend="sql-vacuum"/> and <xref linkend="app-psql"/> 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 <application>libpq</application> front-end library will apply. 問題が発生した場合、考えられる原因とエラーメッセージについての説明はVACUUMpsqlを参照してください。 データベースサーバは、指定したホストで稼働している必要があります。 また、libpqフロントエンドライブラリのデフォルトの設定や環境変数が適用されることに注意してください。

注釈

<title>Notes</title>

<application>vacuumdb</application> might need to connect several times to the <productname>PostgreSQL</productname> server, asking for a password each time. It is convenient to have a <filename>~/.pgpass</filename> file in such cases. See <xref linkend="libpq-pgpass"/> for more information. vacuumdbの実行中にはPostgreSQLサーバに何度も接続しなければならないことがありますが、この場合その度にパスワードが必要です。 そのような場合は~/.pgpassファイルを用意しておくと便利です。 詳細は34.16を参照してください。

<title>Examples</title>

To clean the database <literal>test</literal>: testというデータベースをクリーンアップするには、下記のコマンドを実行します。

$ vacuumdb test

To clean and analyze for the optimizer a database named <literal>bigdb</literal>: bigdbという名前のデータベースのクリーンアップとオプティマイザ用の解析を行う場合には、下記のコマンドを実行します。

$ vacuumdb --analyze bigdb

To clean a single table <literal>foo</literal> in a database named <literal>xyzzy</literal>, and analyze a single column <literal>bar</literal> of the table for the optimizer: xyzzyという名前のデータベースのfooという1つのテーブルだけのクリーンアップと、そのテーブルのbarという1つの列にだけ対してオプティマイザ用の解析を行う場合には、下記のコマンドを実行します。

$ vacuumdb --analyze --verbose --table='foo(bar)' xyzzy

To clean all tables in the <literal>foo</literal> and <literal>bar</literal> schemas in a database named <literal>xyzzy</literal>: xyzzyという名前のデータベースのfooスキーマとbarスキーマのすべてのテーブルをクリーンアップする場合には、下記のコマンドを実行します。

$ vacuumdb --schema='foo' --schema='bar' xyzzy

関連項目

<title>See Also</title> VACUUM