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

VACUUM

VACUUM <refpurpose>garbage-collect and optionally analyze a database</refpurpose> — データベースの不要領域の回収とデータベースの解析(オプション)を行う

概要

VACUUM [ ( option [, ...] ) ] [ table_and_columns [, ...] ]
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ table_and_columns [, ...] ]


<phrase>where <replaceable class="parameter">option</replaceable> can be one of:</phrase>

ここでoptionは以下の一つであり、

    FULL [ boolean ]
    FREEZE [ boolean ]
    VERBOSE [ boolean ]
    ANALYZE [ boolean ]
    DISABLE_PAGE_SKIPPING [ boolean ]
    SKIP_LOCKED [ boolean ]
    INDEX_CLEANUP { AUTO | ON | OFF }
    PROCESS_MAIN [ boolean ]
    PROCESS_TOAST [ boolean ]
    TRUNCATE [ boolean ]
    PARALLEL integer
    SKIP_DATABASE_STATS [ boolean ]
    ONLY_DATABASE_STATS [ boolean ]
    BUFFER_USAGE_LIMIT [ size ]


<phrase>and <replaceable class="parameter">table_and_columns</replaceable> is:</phrase>

table_and_columnsは以下の通りです。

    table_name [ ( column_name [, ...] ) ]

説明

<title>Description</title>

<command>VACUUM</command> reclaims storage occupied by dead tuples. In normal <productname>PostgreSQL</productname> operation, tuples that are deleted or obsoleted by an update are not physically removed from their table; they remain present until a <command>VACUUM</command> is done. Therefore it's necessary to do <command>VACUUM</command> periodically, especially on frequently-updated tables. VACUUM は、無効タプルが使用する領域を回収します。 PostgreSQLの通常動作では、削除されたタプルや更新によって不要となったタプルは、テーブルから物理的には削除されません。 これらのタプルはVACUUMが完了するまで存在し続けます。 そのため、特に更新頻度が多いテーブルでは、VACUUMを定期的に実行する必要があります。

Without a <replaceable class="parameter">table_and_columns</replaceable> list, <command>VACUUM</command> processes every table and materialized view in the current database that the current user has permission to vacuum. With a list, <command>VACUUM</command> processes only those table(s). table_and_columnsリストを指定しない場合、VACUUMは現在のユーザがバキュームできる権限を持つ、現在のデータベース内の全てのテーブルとマテリアライズドビューを処理します。 リストを指定した場合、VACUUMは指定したテーブルのみを処理します。

<command>VACUUM ANALYZE</command> performs a <command>VACUUM</command> and then an <command>ANALYZE</command> for each selected table. This is a handy combination form for routine maintenance scripts. See <xref linkend="sql-analyze"/> for more details about its processing. VACUUM ANALYZEは、指定したテーブルの1つひとつに対し、VACUUMを行った後、ANALYZEを行います。 このコマンドの組合わせは、日常的な管理スクリプトで使うと便利です。 処理の詳細に関しては、ANALYZEを参照してください。

Plain <command>VACUUM</command> (without <literal>FULL</literal>) simply reclaims space and makes it available for re-use. This form of the command can operate in parallel with normal reading and writing of the table, as an exclusive lock is not obtained. However, extra space is not returned to the operating system (in most cases); it's just kept available for re-use within the same table. It also allows us to leverage multiple CPUs in order to process indexes. This feature is known as <firstterm>parallel vacuum</firstterm>. To disable this feature, one can use <literal>PARALLEL</literal> option and specify parallel workers as zero. <command>VACUUM FULL</command> rewrites the entire contents of the table into a new disk file with no extra space, allowing unused space to be returned to the operating system. This form is much slower and requires an <literal>ACCESS EXCLUSIVE</literal> lock on each table while it is being processed. FULLが指定されていない)通常のVACUUMは、単に領域を回収し、そこを再利用可能な状態に変更します。 この形式のコマンドでは排他的ロックを取得しないため、テーブルへの通常の読み書き操作と並行して実行することができます。 しかし余った領域はオペレーティングシステムには(ほとんどの場合)返されません。 同じテーブル内で再利用できるように保持されるだけです。 また、インデックスを処理するために複数のCPUを活用することもできます。 この機能は、並列バキュームとして知られています。 この機能を無効にするには、PARALLELオプションでパラレルワーカーの数をゼロに指定します。 VACUUM FULLでは、テーブルの内容全体を新しいディスクファイルに領域を余すことなく書き換えるため、オペレーティングシステムに未使用の領域を返すことができます。 この形式では、実行速度がかなり低速になります。また、処理中のテーブルに対するACCESS EXCLUSIVEロックが必要になります。

When the option list is surrounded by parentheses, the options can be written in any order. Without parentheses, options must be specified in exactly the order shown above. The parenthesized syntax was added in <productname>PostgreSQL</productname> 9.0; the unparenthesized syntax is deprecated. オプションリストが括弧でくくられていた場合、オプションを任意の順序で記述することができます。 括弧がないと、オプションは上で示した通りの順番で指定しなければなりません。 括弧付きの構文はPostgreSQL 9.0で追加されました。 カッコがない構文は廃止予定です。

パラメータ

<title>Parameters</title>
FULL

Selects <quote>full</quote> vacuum, which can reclaim more space, but takes much longer and exclusively locks the table. This method also requires extra disk space, since it writes a new copy of the table and doesn't release the old copy until the operation is complete. Usually this should only be used when a significant amount of space needs to be reclaimed from within the table. より多くの領域の回収することができる完全なバキュームを選択します。 ただし、通常よりも処理に時間がかかります。 また、テーブルに対する排他ロックが必要です。 またこの方式では、テーブルのコピーを新しく書き出し、操作が終わるまで古いコピーが解放されませんので、余分にディスク領域が必要です。 通常、大きな容量がテーブルから回収されなければならない場合にのみこれが使用されるべきです。

FREEZE

Selects aggressive <quote>freezing</quote> of tuples. Specifying <literal>FREEZE</literal> is equivalent to performing <command>VACUUM</command> with the <xref linkend="guc-vacuum-freeze-min-age"/> and <xref linkend="guc-vacuum-freeze-table-age"/> parameters set to zero. Aggressive freezing is always performed when the table is rewritten, so this option is redundant when <literal>FULL</literal> is specified. 積極的なタプルの凍結を選択します。 FREEZE指定は、vacuum_freeze_min_ageおよびvacuum_freeze_table_ageパラメータをゼロとしてVACUUMを実行することと同じです。 テーブルが書き換えられる時は、必ず積極的な凍結が行われるので、FULLが指定されているときは、このオプションは冗長です。

VERBOSE

Prints a detailed vacuum activity report for each table. 各テーブルについてバキューム処理の詳細な報告を出力します。

ANALYZE

Updates statistics used by the planner to determine the most efficient way to execute a query. プランナが使用する統計情報を更新し、問い合わせを実行する最も効率的な方法を決定できるようにします。

DISABLE_PAGE_SKIPPING

Normally, <command>VACUUM</command> will skip pages based on the <link linkend="vacuum-for-visibility-map">visibility map</link>. Pages where all tuples are known to be frozen can always be skipped, and those where all tuples are known to be visible to all transactions may be skipped except when performing an aggressive vacuum. Furthermore, except when performing an aggressive vacuum, some pages may be skipped in order to avoid waiting for other sessions to finish using them. This option disables all page-skipping behavior, and is intended to be used only when the contents of the visibility map are suspect, which should happen only if there is a hardware or software issue causing database corruption. 通常、VACUUM可視性マップに基いてページをスキップします。 すべてのタプルが凍結されていることがわかっているページは、常にスキップできます。 また、すべてのタプルがすべてのトランザクションに対して可視であることがわかっているページは、積極的なバキュームを実行している場合を除き、スキップできます。 さらに、積極的なバキュームを実行している場合を除き、一部のページは、他のセッションがその使用を終了するのを待つのを避けるため、スキップされます。 このオプションは、ページをスキップする動作をすべて無効にします。 これは可視性マップの内容が怪しいときにのみ使用されることを意図したもので、それはデータベースの破損を引き起こすようなハードウェアあるいはソフトウェアの障害がある場合にのみ発生します。

SKIP_LOCKED

Specifies that <command>VACUUM</command> should not wait for any conflicting locks to be released when beginning work on a relation: if a relation cannot be locked immediately without waiting, the relation is skipped. Note that even with this option, <command>VACUUM</command> may still block when opening the relation's indexes. Additionally, <command>VACUUM ANALYZE</command> may still block when acquiring sample rows from partitions, table inheritance children, and some types of foreign tables. Also, while <command>VACUUM</command> ordinarily processes all partitions of specified partitioned tables, this option will cause <command>VACUUM</command> to skip all partitions if there is a conflicting lock on the partitioned table. VACUUMに、リレーションでの作業開始時、衝突するロックが解放されるのを待たないよう指定します。リレーションが待たずにすぐにロックできない場合、そのリレーションは飛ばされます。 このオプションを指定しても、リレーションのインデックスを開く時にVACUUMはブロックするかもしれないことに注意してください。 さらに加えて、VACUUM ANALYZEは、パーティションやテーブル継承の子、ある種類の外部テーブルからサンプル行を取得する時にブロックするかもしれません。 また、VACUUMは通常、指定されたパーティションテーブルの全パーティションを処理しますが、このオプションが指定されると、パーティションテーブルに衝突するロックがある場合VACUUMは全パーティションを飛ばすようになります。

INDEX_CLEANUP

Normally, <command>VACUUM</command> will skip index vacuuming when there are very few dead tuples in the table. The cost of processing all of the table's indexes is expected to greatly exceed the benefit of removing dead index tuples when this happens. This option can be used to force <command>VACUUM</command> to process indexes when there are more than zero dead tuples. The default is <literal>AUTO</literal>, which allows <command>VACUUM</command> to skip index vacuuming when appropriate. If <literal>INDEX_CLEANUP</literal> is set to <literal>ON</literal>, <command>VACUUM</command> will conservatively remove all dead tuples from indexes. This may be useful for backwards compatibility with earlier releases of <productname>PostgreSQL</productname> where this was the standard behavior. 通常、VACUUMは、テーブル内に無効なタプルがほとんどない場合インデックスのバキュームをスキップします。 テーブルのインデックスをすべて処理するコストは、無効なインデックスタプルを削除した場合にそれにより得られる利益を大きく上回ると考えられます。 このオプションは、無効なタプルが1つ以上ある場合にVACUUMにインデックスを強制的に処理させるのに使えます。 デフォルトはAUTOで、適切な場合VACUUMはインデックスのバキュームをスキップします。 INDEX_CLEANUPONに設定されていれば、VACUUMは保守的にインデックスから無効なタプルをすべて削除します。 この動作が標準だったPostgreSQLの以前のリリースとの後方互換性のためには、これは有用かもしれません。

<literal>INDEX_CLEANUP</literal> can also be set to <literal>OFF</literal> to force <command>VACUUM</command> to <emphasis>always</emphasis> skip index vacuuming, even when there are many dead tuples in the table. This may be useful when it is necessary to make <command>VACUUM</command> run as quickly as possible to avoid imminent transaction ID wraparound (see <xref linkend="vacuum-for-wraparound"/>). However, the wraparound failsafe mechanism controlled by <xref linkend="guc-vacuum-failsafe-age"/> will generally trigger automatically to avoid transaction ID wraparound failure, and should be preferred. If index cleanup is not performed regularly, performance may suffer, because as the table is modified indexes will accumulate dead tuples and the table itself will accumulate dead line pointers that cannot be removed until index cleanup is completed. INDEX_CLEANUPOFFに設定して、VACUUM必ずインデックスのバキュームをスキップするよう強制することもできます。テーブルに多くの無効なタプルがある場合でさえも同様です。 切迫したトランザクションIDの周回を避けるためVACUUMをできる限り速く実行することが必要な場合には、これは有用かもしれません(25.1.5を参照してください)。 しかしながら、たいていはvacuum_failsafe_ageにより制御される周回安全機構がトランザクションIDの周回の失敗を避けるために自動的に発動しますし、そちらの方が好ましいです。 インデックスクリーンアップが定期的に実行されていなければ、テーブルが修正されるに従い、インデックスは無効なタプルを蓄積し、テーブル自身もインデックスクリーンアップが完了するまで削除できない無効な行ポインタを蓄積していきますので、性能は悪化するでしょう。

This option has no effect for tables that have no index and is ignored if the <literal>FULL</literal> option is used. It also has no effect on the transaction ID wraparound failsafe mechanism. When triggered it will skip index vacuuming, even when <literal>INDEX_CLEANUP</literal> is set to <literal>ON</literal>. このオプションはテーブルにインデックスがない場合には効果がありませんし、FULLオプションが使われている場合には無視されます。 トランザクションID周回安全機構にも影響はありません。 発動した場合には、INDEX_CLEANUPONに設定されていたとしても、インデックスのバキュームをスキップします。

PROCESS_MAIN

Specifies that <command>VACUUM</command> should attempt to process the main relation. This is usually the desired behavior and is the default. Setting this option to false may be useful when it is only necessary to vacuum a relation's corresponding <literal>TOAST</literal> table. VACUUMが主リレーションの処理を試みるよう指定します。 これは普通は望まれる振舞いであり、デフォルトです。 このオプションを偽に設定するのは、リレーションの対応するTOASTテーブルのバキュームのみが必要な場合には有用かもしれません。

PROCESS_TOAST

Specifies that <command>VACUUM</command> should attempt to process the corresponding <literal>TOAST</literal> table for each relation, if one exists. This is usually the desired behavior and is the default. Setting this option to false may be useful when it is only necessary to vacuum the main relation. This option is required when the <literal>FULL</literal> option is used. 各リレーションに対応するTOASTテーブルが存在するのなら、VACUUMがその処理を試みるよう指定します。 これは普通は望まれる振舞いであり、デフォルトです。 このオプションを偽に設定するのは、主リレーションをバキュームすることだけが必要な場合には有用かもしれません。 FULLオプションを使うときにはこのオプションが必要です。

TRUNCATE

Specifies that <command>VACUUM</command> should attempt to truncate off any empty pages at the end of the table and allow the disk space for the truncated pages to be returned to the operating system. This is normally the desired behavior and is the default unless the <literal>vacuum_truncate</literal> option has been set to false for the table to be vacuumed. Setting this option to false may be useful to avoid <literal>ACCESS EXCLUSIVE</literal> lock on the table that the truncation requires. This option is ignored if the <literal>FULL</literal> option is used. VACUUMに、テーブルの最後にある空のページを切り詰め、切り詰めたページのディスクスペースをオペレーティングシステムに返すよう指定します。 これは普通は望まれる振舞いであり、バキュームされるテーブルに対してvacuum_truncateオプションが偽に設定されていない限りデフォルトです。 このオプションを偽に設定するのは、切り詰めが要求されているテーブルのACCESS EXCLUSIVEロックを回避するのに有用かもしれません。 このオプションはFULLオプションが使われていれば無視されます。

PARALLEL

Perform index vacuum and index cleanup phases of <command>VACUUM</command> in parallel using <replaceable class="parameter">integer</replaceable> background workers (for the details of each vacuum phase, please refer to <xref linkend="vacuum-phases"/>). The number of workers used to perform the operation is equal to the number of indexes on the relation that support parallel vacuum which is limited by the number of workers specified with <literal>PARALLEL</literal> option if any which is further limited by <xref linkend="guc-max-parallel-maintenance-workers"/>. An index can participate in parallel vacuum if and only if the size of the index is more than <xref linkend="guc-min-parallel-index-scan-size"/>. Please note that it is not guaranteed that the number of parallel workers specified in <replaceable class="parameter">integer</replaceable> will be used during execution. It is possible for a vacuum to run with fewer workers than specified, or even with no workers at all. Only one worker can be used per index. So parallel workers are launched only when there are at least <literal>2</literal> indexes in the table. Workers for vacuum are launched before the start of each phase and exit at the end of the phase. These behaviors might change in a future release. This option can't be used with the <literal>FULL</literal> option. integer個のバックグラウンドワーカーを使用して、VACUUMのインデックスバキュームフェーズとインデックスクリーンアップフェーズを並列に実行します(各バキュームフェーズの詳細については、表 28.45を参照してください)。 操作の実行に使用されるワーカーの数は、並列バキュームをサポートするリレーションのインデックスの数と同じです。この数はPARALLELオプションで指定されたワーカーの数によって制限され、max_parallel_maintenance_workersパラメータによってさらに制限されます。 インデックスは、インデックスのサイズがmin_parallel_index_scan_sizeパラメータよりも大きい場合にのみ、並列バキュームに参加できます。 integerで指定されたパラレルワーカー数が実行中に使用されることは保証されないことに注意してください。 指定されたワーカー数より少ないワーカーでバキュームが実行されたり、ワーカーがまったくない状態で実行される可能性があります。 1つのインデックスに使用出来るワーカーは1つだけです。よって、パラレルワーカーはテーブルに少なくとも2つのインデックスがある場合にのみ起動されます。 バキュームのワーカーは、各フェーズの開始前に起動され、フェーズの終了時に終了します。 これらの動作は将来のリリースで変更される可能性があります。このオプションはFULLオプションと一緒に使用することはできません。

SKIP_DATABASE_STATS

Specifies that <command>VACUUM</command> should skip updating the database-wide statistics about oldest unfrozen XIDs. Normally <command>VACUUM</command> will update these statistics once at the end of the command. However, this can take awhile in a database with a very large number of tables, and it will accomplish nothing unless the table that had contained the oldest unfrozen XID was among those vacuumed. Moreover, if multiple <command>VACUUM</command> commands are issued in parallel, only one of them can update the database-wide statistics at a time. Therefore, if an application intends to issue a series of many <command>VACUUM</command> commands, it can be helpful to set this option in all but the last such command; or set it in all the commands and separately issue <literal>VACUUM (ONLY_DATABASE_STATS)</literal> afterwards. VACUUMが、最も古い凍結されていないXIDに関するデータベース全体の統計情報の更新をスキップするように指定します。 通常、VACUUMはこれらの統計情報をコマンドの終わりに一度更新します。 ただし、非常に数多くのテーブルを持つデータベースでは、これには時間がかかる可能性があり、最も古い凍結されていないXIDを含むテーブルがバキュームされたテーブルの中にない限り、何も達成されません。 さらに、複数のVACUUMコマンドが並列に発行された場合、一度にデータベース全体の統計処理を更新できるのはそのうちの1つだけです。 したがって、アプリケーションが多くのVACUUMコマンドを連続して発行しようとする場合、このオプションを最後のコマンドを除くすべてのコマンドに設定するか、すべてのコマンドに設定して後で個別にVACUUM (ONLY_DATABASE_STATS)を発行すると便利でしょう。

ONLY_DATABASE_STATS

Specifies that <command>VACUUM</command> should do nothing except update the database-wide statistics about oldest unfrozen XIDs. When this option is specified, the <replaceable class="parameter">table_and_columns</replaceable> list must be empty, and no other option may be enabled except <literal>VERBOSE</literal>. VACUUMが、最も古い凍結されていないXIDについて、データベース全体の統計情報を更新する以外に何もしないことを指定します。 このオプションを指定する場合、table_and_columnsリストは空である必要があり、VERBOSE以外の他のオプションは有効にできません。

BUFFER_USAGE_LIMIT

Specifies the <glossterm linkend="glossary-buffer-access-strategy">Buffer Access Strategy</glossterm> ring buffer size for <command>VACUUM</command>. This size is used to calculate the number of shared buffers which will be reused as part of this strategy. <literal>0</literal> disables use of a <literal>Buffer Access Strategy</literal>. If <option>ANALYZE</option> is also specified, the <option>BUFFER_USAGE_LIMIT</option> value is used for both the vacuum and analyze stages. This option can't be used with the <option>FULL</option> option except if <option>ANALYZE</option> is also specified. When this option is not specified, <command>VACUUM</command> uses the value from <xref linkend="guc-vacuum-buffer-usage-limit"/>. Higher settings can allow <command>VACUUM</command> to run more quickly, but having too large a setting may cause too many other useful pages to be evicted from shared buffers. The minimum value is <literal>128 kB</literal> and the maximum value is <literal>16 GB</literal>. VACUUMバッファアクセスストラテジリングバッファサイズを指定します。 このサイズは、このストラテジの一部として再利用される共有バッファの数を計算するために使用されます。 0は、バッファアクセスストラテジの使用を無効にします。 ANALYZEも指定されている場合、BUFFER_USAGE_LIMIT値がバキュームと解析の両方のステージに使用されます。 ANALYZEも指定されている場合を除き、このオプションはFULLオプションとともに使用できません。 このオプションが指定されていない場合、VACUUMvacuum_buffer_usage_limitの値を使用します。 設定を高くするとVACUUMの実行速度がより速くなりますが、設定が大き過ぎると、とても多くの他の有用なページが共有バッファから追い出されてしまう可能性があります。 最小値は 128 kB、最大値は 16 GBです。

boolean

Specifies whether the selected option should be turned on or off. You can write <literal>TRUE</literal>, <literal>ON</literal>, or <literal>1</literal> to enable the option, and <literal>FALSE</literal>, <literal>OFF</literal>, or <literal>0</literal> to disable it. The <replaceable class="parameter">boolean</replaceable> value can also be omitted, in which case <literal>TRUE</literal> is assumed. 選択されたオプションを有効にするか無効にするかを指定します。 オプションを有効にするにはTRUEONまたは1と書くことができ、無効にするにはFALSEOFFまたは0と書くことができます。 boolean値は省略することもでき、その場合にはTRUEとみなされます。

integer

Specifies a non-negative integer value passed to the selected option. 選択したオプションに渡される負でない整数値を指定します。

size

Specifies an amount of memory in kilobytes. Sizes may also be specified as a string containing the numerical size followed by any one of the following memory units: <literal>kB</literal> (kilobytes), <literal>MB</literal> (megabytes), <literal>GB</literal> (gigabytes), or <literal>TB</literal> (terabytes). メモリの量をキロバイト単位で指定します。 サイズは、数値のサイズに続いて、kB(キロバイト)、MB(メガバイト)、GB(ギガバイト)またはTB(テラバイト)のいずれか1つのメモリ単位を含む文字列として指定することもできます。

table_name

The name (optionally schema-qualified) of a specific table or materialized view to vacuum. If the specified table is a partitioned table, all of its leaf partitions are vacuumed. バキューム対象のテーブルまたはマテリアライズドビューの名前です(スキーマ修飾名も可)。 指定したテーブルがパーティションテーブルの場合、そのすべてのリーフパーティションがバキュームされます。

column_name

The name of a specific column to analyze. Defaults to all columns. If a column list is specified, <literal>ANALYZE</literal> must also be specified. 解析の対象とする列名です。 デフォルトは全列です。 列リストが指定された場合はANALYZEも指定しなければいけません。

出力

<title>Outputs</title>

When <literal>VERBOSE</literal> is specified, <command>VACUUM</command> emits progress messages to indicate which table is currently being processed. Various statistics about the tables are printed as well. VERBOSEが指定された場合、VACUUMは、現在処理中のテーブルを示す進行状況メッセージを表示します。 同様に、テーブルについての各種の統計情報も表示されます。

注釈

<title>Notes</title>

To vacuum a table, one must ordinarily be the table's owner or a superuser. However, database owners are allowed to vacuum all tables in their databases, except shared catalogs. (The restriction for shared catalogs means that a true database-wide <command>VACUUM</command> can only be performed by a superuser.) <command>VACUUM</command> will skip over any tables that the calling user does not have permission to vacuum. テーブルをバキュームするためには、通常はテーブルの所有者もしくはスーパーユーザでなければなりません。 しかしデータベースの所有者は共有カタログを除くデータベース内の全テーブルをバキュームすることができます。 (共有カタログに関する制限は、データベース全体のVACUUMはスーパーユーザのみが実行可能であることを意味します。) VACUUMは、呼び出したユーザがバキュームするための権限を持たないテーブルはすべて飛ばします。

<command>VACUUM</command> cannot be executed inside a transaction block. トランザクションブロック内でVACUUMを実行することはできません。

For tables with <acronym>GIN</acronym> indexes, <command>VACUUM</command> (in any form) also completes any pending index insertions, by moving pending index entries to the appropriate places in the main <acronym>GIN</acronym> index structure. See <xref linkend="gin-fast-update"/> for details. GINインデックスを持つテーブルでは、VACUUM(全構文)は待ち状態のインデックス挿入を主GINインデックス構造内の適切なところに移動させることにより、待ち状態のインデックス挿入をすべて完了させます。 70.4.1を参照してください。

We recommend that all databases be vacuumed regularly in order to remove dead rows. <productname>PostgreSQL</productname> includes an <quote>autovacuum</quote> facility which can automate routine vacuum maintenance. For more information about automatic and manual vacuuming, see <xref linkend="routine-vacuuming"/>. 無効な行を削除するために、データベースすべてを定期的にバキュームすることをお勧めします。 PostgreSQLには、バキューム保守作業を自動化するautovacuum機能があります。 自動バキューム処理および手作業によるバキューム処理に関する詳細については、25.1を参照してください。

The <option>FULL</option> option is not recommended for routine use, but might be useful in special cases. An example is when you have deleted or updated most of the rows in a table and would like the table to physically shrink to occupy less disk space and allow faster table scans. <command>VACUUM FULL</command> will usually shrink the table more than a plain <command>VACUUM</command> would. FULLオプションを日常的に使用することは推奨しませんが、特殊なケースでは有用となる場合もあります。 例えば、テーブル内のほとんど全ての行を削除または更新し、そのテーブルによるディスクの使用量を物理的に縮小させて高速なテーブルスキャンを行いたい場合です。 VACUUM FULLはたいていの場合、通常のVACUUMよりもテーブルを縮小します。

The <option>PARALLEL</option> option is used only for vacuum purposes. If this option is specified with the <option>ANALYZE</option> option, it does not affect <option>ANALYZE</option>. PARALLELオプションはバキュームの用途でのみ使用されます。 このオプションをANALYZEオプションで指定した場合、ANALYZEには影響しません。

<command>VACUUM</command> causes a substantial increase in I/O traffic, which might cause poor performance for other active sessions. Therefore, it is sometimes advisable to use the cost-based vacuum delay feature. For parallel vacuum, each worker sleeps in proportion to the work done by that worker. See <xref linkend="runtime-config-resource-vacuum-cost"/> for details. VACUUMによりI/Oトラフィックがかなり増大しますので、実行中の他のセッションの性能が悪化する可能性があります。 このため、コストベースのバキューム遅延機能の使用が推奨される場合があります。 並列バキュームの場合、各ワーカーはそのワーカーが行った作業に比例してスリープします。 詳細は20.4.4を参照してください。

Each backend running <command>VACUUM</command> without the <literal>FULL</literal> option will report its progress in the <structname>pg_stat_progress_vacuum</structname> view. Backends running <command>VACUUM FULL</command> will instead report their progress in the <structname>pg_stat_progress_cluster</structname> view. See <xref linkend="vacuum-progress-reporting"/> and <xref linkend="cluster-progress-reporting"/> for details. VACUUMFULLオプションなしで実行している各バックエンドはその進捗をpg_stat_progress_vacuumビューで報告します。 VACUUM FULLを実行しているバックエンドはその代わりにその進捗をpg_stat_progress_clusterビューで報告します。 詳細は28.4.528.4.2を参照してください。

<title>Examples</title>

To clean a single table <literal>onek</literal>, analyze it for the optimizer and print a detailed vacuum activity report: onek というテーブル1つだけを掃除し、オプティマイザ用に解析し、バキューム処理の詳細な報告を出力するには、次のようにします。

VACUUM (VERBOSE, ANALYZE) onek;

互換性

<title>Compatibility</title>

There is no <command>VACUUM</command> statement in the SQL standard. 標準SQLにはVACUUM文はありません。

関連項目

<title>See Also</title> vacuumdb, 20.4.4, 25.1.6, 28.4.5, 28.4.2