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

25.2. 定常的なインデックスの再作成 #

<title>Routine Reindexing</title>

In some situations it is worthwhile to rebuild indexes periodically with the <xref linkend="sql-reindex"/> command or a series of individual rebuilding steps. REINDEXコマンドまたは一連の個々の再構築処理を使用して定期的にインデックスを再構築することが価値がある状況があります。

B-tree index pages that have become completely empty are reclaimed for re-use. However, there is still a possibility of inefficient use of space: if all but a few index keys on a page have been deleted, the page remains allocated. Therefore, a usage pattern in which most, but not all, keys in each range are eventually deleted will see poor use of space. For such usage patterns, periodic reindexing is recommended. 完全に空になったB-treeインデックスページは再利用のために回収されます。 しかしまだ非効率的な領域使用の可能性があります。 ページからわずかを残しほとんどすべてのインデックスキーが削除されたとしても、ページは割り当てられたまま残ります。 各範囲において、わずかを残しほとんどすべてのキーが削除されるようなパターンで使用されると、領域が無駄に使用されることが分かります。 こうした使用状況では、定期的なインデックス再構築を推奨します。

The potential for bloat in non-B-tree indexes has not been well researched. It is a good idea to periodically monitor the index's physical size when using any non-B-tree index type. B-tree以外のインデックスが膨張する可能性はまだよく調査されていません。 B-tree以外の任意の種類のインデックスを使用する際には、インデックスの物理容量を定期的に監視することを勧めます。

Also, for B-tree indexes, a freshly-constructed index is slightly faster to access than one that has been updated many times because logically adjacent pages are usually also physically adjacent in a newly built index. (This consideration does not apply to non-B-tree indexes.) It might be worthwhile to reindex periodically just to improve access speed. また、B-treeインデックスでは、新規に構築したインデックスの方が何度も更新されたインデックスよりもアクセスが多少高速です。 新しく構築されたインデックスでは論理的に近接するページが通常物理的にも近接するからです。 (これはB-tree以外のインデックスではあてはまりません。) アクセス速度を向上させるためだけに周期的にインデックスを再構築することは価値があるかもしれません。

<xref linkend="sql-reindex"/> can be used safely and easily in all cases. This command requires an <literal>ACCESS EXCLUSIVE</literal> lock by default, hence it is often preferable to execute it with its <literal>CONCURRENTLY</literal> option, which requires only a <literal>SHARE UPDATE EXCLUSIVE</literal> lock. REINDEXはすべての状況で安全に簡単に使うことができます。 このコマンドはデフォルトでACCESS EXCLUSIVEロックを要求しますので、CONCURRENTLYオプションを付けて実行する方が好ましい場合がしばしばあります。その場合にはSHARE UPDATE EXCLUSIVEロックしか要求しません。