VACUUM

Name

VACUUM -- Clean and analyze a Postgres database Postgres データベースのゴミ掃除と解析 を行なう。

Synopsis

VACUUM [ VERBOSE ] [ ANALYZE ] [ table ]
VACUUM [ VERBOSE ] ANALYZE [ table [ (column [, ...] ) ] ]

入力

VERBOSE

Prints a detailed vacuum activity report for each table.

各テーブルについて vacuum の詳細な活動報告を出力します。

ANALYZE

Updates column statistics used by the optimizer to determine the most efficient way to execute a query. The statistics represent the disbursion of the data in each column. This information is valuable when several execution paths are possible.

オブティマイザが問い合わせの実行に最も効率的な方法を決 定する際に使用するカラムの統計情報を更新します。統計情 報は各カラム内のデータの分布状況を表すものです。この情報は 複数の実行経路があり得る時に重要なものです。

table

The name of a specific table to vacuum. Defaults to all tables.

vacuum の対象とするテーブルの名前。デフォルトは全テー ブルです。

column

The name of a specific column to analyze. Defaults to all columns.

解析の対象とするカラムの名前。デフォルトは全カラムです。

出力

VACUUM

The command has been accepted and the database is being cleaned.

コマンドは受け付けられ、データベースのゴミ掃除が完了しました。

NOTICE: --Relation table--

The report header for table.

table に 関する報告のヘッダです。

NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0; Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188; Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74. Elapsed 0/0 sec.

The analysis for table itself.

table に 関する解析結果そのものです。

NOTICE: Index index: Pages 28; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.

The analysis for an index on the target table.

対象テーブルのインデックスに関する解析結果です。

説明

VACUUM serves two purposes in Postgres as both a means to reclaim storage and also a means to collect information for the optimizer.

Postgres における VACUUM には保存領域の回収・確保のための手段 とオプティマイザ用の情報収集のため手段という 2 つの使いみちがあ ります。

VACUUM opens every class in the database, cleans out records from rolled back transactions, and updates statistics in the system catalogs. The statistics maintained include the number of tuples and number of pages stored in all classes. Running VACUUM periodically will increase the speed of the database in processing user queries.

VACUUMは、データベース内の全クラスを開き、 トランザクションからのロールバック用のレコードを空にし、シス テムカタログ内の統計情報を更新します。統計情報として保全され るものには、タプル数と全クラスを保存しているページの数があり ます。VACUUM を定期的に実行すれば、データ ベースに対するユーザからの問い合わせの処理速度が向上します。

注意

The open database is target for VACUUM.

開いているデータベースが VACUUM の対象と なります。

We recommend that active production databases be cleaned nightly, in order to keep statistics relatively current. The VACUUM query may be executed at any time, however. In particular, after copying a large class into Postgres or after deleting a large number of records, it may be a good idea to issue a VACUUM query. This will update the system catalogs with the results of all recent changes, and allow the Postgres query optimizer to make better choices in planning user queries.

統計情報を相対的に見て現時点のものを維持しているといえる状態 にしておくために、実際に運用されているデータベースを毎晩ゴミ 掃除しておくことをお勧めします。しかし、 VACUUM はいつ行なわれても構いません。特に 大きなクラスを Postgres にコピーし た後や多くのレコードを削除した後の VACUUM の発行を行なうことはおそらく良いことでしょう。これによりシス テムカタログは最近なされた変更の全てを反映したものになり、そ して、Postgres の問い合わせオプテ ィマイザがユーザ問い合わせの計画作成時により良い選択をできる ようになります。

If the server crashes during a VACUUM command, chances are it will leave a lock file hanging around. Attempts to re-run the VACUUM command result in an error message about the creation of a lock file. If you are sure VACUUM is not running, remove the pg_vlock file in your database directory (i.e. PGDATA/base/dbname/pg_vlock).

VACUUM コマンド実行中にサーバが壊れた場合、 偶然にロックファイルが待ち状態のまま残ってしまうことがありま す。VACUUM コマンドを再実行しようとしても、 ロックファイルの作成についてのエラーメッセージが表示されるこ とになります。VACUUM 実行中でないことを確 認してから、データベースディレクトリの pg_vlock ファイル(つまり PGDATA/base/dbname/pg_vlock )を削除して下さい。

使用法

The following is an example from running VACUUM on a table in the regression database:

以下の例は、regression データベース内のテーブルに VACUUM を実行したものです。

regression=> vacuum verbose analyze onek;
NOTICE:  --Relation onek--
NOTICE:  Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
         Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188;
         Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74.
         Elapsed 0/0 sec.
NOTICE:  Index onek_stringu1: Pages 28; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
NOTICE:  Index onek_hundred: Pages 12; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
NOTICE:  Index onek_unique2: Pages 19; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
NOTICE:  Index onek_unique1: Pages 17; Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
NOTICE:  Rel onek: Pages: 98 --> 25; Tuple(s) moved: 1000. Elapsed 0/1 sec.
NOTICE:  Index onek_stringu1: Pages 28; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
NOTICE:  Index onek_hundred: Pages 12; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
NOTICE:  Index onek_unique2: Pages 19; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
NOTICE:  Index onek_unique1: Pages 17; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
VACUUM
      

互換性

SQL92

There is no VACUUM statement in SQL92.

SQL92には VACUUM 文はありません。