.\" This is -*-nroff-*- .\" XXX standard disclaimer belongs here.... .\" $Header: /usr/local/cvsroot/pgsql/src/man/cluster.l,v 1.7 1998/03/15 02:13:23 momjian Exp $ .\" .\" Japanese Version Copyright (c) 1998 Michihide Hotta .\" all rights reserved. .\" Translated Wed Jun 3 18:46:34 JST 1998 .\" by Michihide Hotta .\" .TH CLUSTER SQL 01/23/93 PostgreSQL PostgreSQL .\"0 .SH NAME .\"0 cluster - give storage clustering advice to Postgres .SH 名前 cluster - Postgres に対して、記憶領域のクラスタリングの 指示を与える。 .\"0 .SH SYNOPSIS .\"0 .nf .\"0 \fBcluster\fR indexname \fBon\fR attname .\"0 .fi .SH 書式 .nf \fBcluster\fR インデックス名 \fBon\fR 属性名 .fi .\"0 .SH DESCRIPTION .\"0 This command instructs Postgres to cluster the class .\"0 specified by .\"0 .IR classname .\"0 approximately based on the index specified by .\"0 .IR indexname. .\"0 The index must already have been defined on .\"0 .IR classname. .SH 説明 このコマンドは Postgres に対して、 .IR インデックス名 で指定されたインデックス順にだいたい並んでいる .IR クラス名 で指定されたクラスをクラスタリングするように指示する。 .PP .\"0 When a class is clustered, it is physically reordered based .\"0 on the index information. The clustering is static. In other .\"0 words, as the class is updated, the changes are not clusterd. .\"0 No attempt is made to keep new instances or updated tuples .\"0 clustered. If desired, the user can recluster manually by .\"0 issuing the command again. クラスがまとめられると、それはインデックス情報に基づいて物理的に 並べ替えられる。クラスタリングは静的に行われる。つまりクラスが 更新されても、変更分はクラスタリングされない。新しいインスタンス や更新されたタプルはクラスタリングに反映されない。もしそう望むの であれば、ユーザがこのコマンドを手作業で再発行することにより、 再クラスタリングを行うことができる。 .PP .\"0 The table is actually copied to temporary table in index order, .\"0 then renamed back to the original name. For this reason, all .\"0 grant permissions and other indexes are lost when cluster is .\"0 performed. 実際にテーブルは、インデックス順で一時テーブルにコピーされ、 その後新しい名前にリネームされる。これは、クラスタリングが実行 される際に、許可されたすべての権限やその他のインデックスなどが 失われてしまうためである。 .PP .\"0 In cases where you are accessing single rows randomly within a .\"0 table, the actual order of the data in the heap table .\"0 unimportant. However, if you tend to access some data more .\"0 than others, and there is an index that groups them together, .\"0 you will benefit from using the CLUSTER command. テーブル内の単一行に対してランダムにアクセスしている場合、 ヒープテーブル内における実際のデータの並び方は重要ではない。 しかしながら、それ以外のデータにアクセスしたい場合で、 それらがお互いにグループ化されている場合は、CLUSTER コマンド が役に立つ。 .PP .\"0 Another place CLUSTER is good is in cases where you use an index .\"0 to pull out several rows from a table. If you are requesting a .\"0 range of indexed values from a table, or a single indexed value .\"0 that has multiple rows that match, CLUSTER will help because .\"0 once the index identifies the heap page for the first row that .\"0 matches, all other rows that match are probably already on the .\"0 same heap page, saving disk accesses and speeding up the query. CLUSTER が役に立つもう 1 つの場面としては、インデックスを使って テーブルからいくつかの行を取り出す場合があげられる。テーブルから インデックスされた値のうちのある範囲を要求する場合、または、単一の インデックス値がマッチする複数の行がある場合、CLUSTER は役に立つ。 これは、インデックスはいったんマッチする最初の行をヒープページ内 から特定すると、その他すべてのマッチする行は、おそらくすでに同じ ヒープページの中にあるので、ディスクアクセスを削減し、問い合わせ が高速化されることになるからである。 .PP .\"0 There are two ways to cluster data. The first is with the .\"0 CLUSTER command, which reoreders the original table with .\"0 the ordering of the index you specify. This can be slow .\"0 on large tables because the rows are fetched from the heap .\"0 in index order, and if the heap table is unordered, the .\"0 entries are on random pages, so there is one disk page .\"0 retrieved for every row moved. PostgreSQL has a cache, .\"0 but the majority of a big table will not fit in the cache. データをクラスタ化するには 2 つの方法がある。1 つは、CLUSTER コマンドで、オリジナルのテーブルを指定したインデックス順に並べ 替えることである。この方法は、巨大なテーブルの場合は遅くなる。 これは、各行はヒープからインデックス順に取り出されるので、もし ヒープテーブルが並んでいない場合は、エントリはランダムなページ 上にあり、各行の移動の際にレコードを取り出すたびに 1 回の ディスクアクセスが行われるからである。PostgreSQL はキャッシュ を持ってはいるが、一般的に大きなテーブルはキャッシュの中には 入りきれない。 .PP .\"0 Another way is to use SELECT ... INTO TABLE temp FROM ...ORDER .\"0 BY ... . This uses the PostgreSQL sorting code in ORDER BY to .\"0 match the index, and is much faster for unordered data. You .\"0 then drop the old table, use ALTER TABLE RENAME to rename .\"0 'temp' to the old name, and recreate the bbindexes. The only .\"0 problem is that oids will not be preserved. From then on, .\"0 CLUSTER should be fast because most of the heap data has .\"0 already been ordered, and the existing index is used. もう 1 つの方法としては、SELECT ... INTO TABLE temp FROM ... ORDER BY ... を使用することがある。これは、ORDER BY の中で、 インデックスにマッチさせるのに PostgreSQL のソートルーチン を使うので、並んでいないデータに対してはより早くなる。 そしてそのあと古いテーブルを drop し、 ALTER TABLE RENAME で 'temp' を古い名前にリネームし、the bbindexe を再作成する。 ただ 1 つの問題は、oid が保存されないことである。これらの ことから、ヒープデータのほとんどはすでに並び変わっており、 存在するインデックスが使われるのであれば、CLUSTER の方が速い ということになる。 .\"0 .SH EXAMPLE .\"0 .nf .\"0 /* .\"0 * cluster employees in based on its salary attribute .\"0 */ .\"0 create index emp_ind on emp using btree (salary int4_ops); .\"0 .\"0 cluster emp_ind on emp .\"0 .fi .SH 例 .nf /* * 従業員を彼らの給与属性を元にクラスタ化する */ create index 従業員_ind on 従業員 using btree (給与 int4_ops); cluster 従業員_ind on 従業員 .fi .SH 翻訳者 堀田 倫英