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

F.9. btree_gist — GiST演算子クラスとB-tree動作 #

<title>btree_gist &mdash; GiST operator classes with B-tree behavior</title>

<filename>btree_gist</filename> provides GiST index operator classes that implement B-tree equivalent behavior for the data types <type>int2</type>, <type>int4</type>, <type>int8</type>, <type>float4</type>, <type>float8</type>, <type>numeric</type>, <type>timestamp with time zone</type>, <type>timestamp without time zone</type>, <type>time with time zone</type>, <type>time without time zone</type>, <type>date</type>, <type>interval</type>, <type>oid</type>, <type>money</type>, <type>char</type>, <type>varchar</type>, <type>text</type>, <type>bytea</type>, <type>bit</type>, <type>varbit</type>, <type>macaddr</type>, <type>macaddr8</type>, <type>inet</type>, <type>cidr</type>, <type>uuid</type>, <type>bool</type> and all <type>enum</type> types. btree_gistは、次に列挙するデータ型に対しB-treeと同等な動作を実装するGiSTインデックス演算子クラスを提供します。データ型は、int2int4int8float4float8numerictimestamp with time zonetimestamp without time zonetime with time zonetime without time zonedateintervaloidmoneycharvarchartextbyteabitvarbitmacaddrmacaddr8inetcidruuidbool、およびすべてのenum型です。

In general, these operator classes will not outperform the equivalent standard B-tree index methods, and they lack one major feature of the standard B-tree code: the ability to enforce uniqueness. However, they provide some other features that are not available with a B-tree index, as described below. Also, these operator classes are useful when a multicolumn GiST index is needed, wherein some of the columns are of data types that are only indexable with GiST but other columns are just simple data types. Lastly, these operator classes are useful for GiST testing and as a base for developing other GiST operator classes. 一般的に、これらの演算子クラスは同等な標準B-treeインデックス方式を性能的に凌駕する物ではなく、標準B-treeコードの1つの重要機能である一意性強要の能力を欠いています。 しかしながら、以下で述べるようにB-treeインデックスにはない特徴をいくつか備えています。 また、これらの演算子クラスは、GiSTでのみインデックス可能なデータ型の列もあれば、単純なデータ型の列もあるような複数列のGiSTインデックスが必要な場合に便利です。 最後に、GiSTの試験、およびその他のGiST演算子クラスの開発の基礎として便利です。

In addition to the typical B-tree search operators, <filename>btree_gist</filename> also provides index support for <literal>&lt;&gt;</literal> (<quote>not equals</quote>). This may be useful in combination with an <link linkend="sql-createtable-exclude">exclusion constraint</link>, as described below. 典型的なB-tree検索演算子に加えて、btree_gist<>等しくない)に対してもインデックスのサポートを提供します。 これは、後で述べるような排他制約と組み合わせると便利でしょう。

Also, for data types for which there is a natural distance metric, <filename>btree_gist</filename> defines a distance operator <literal>&lt;-&gt;</literal>, and provides GiST index support for nearest-neighbor searches using this operator. Distance operators are provided for <type>int2</type>, <type>int4</type>, <type>int8</type>, <type>float4</type>, <type>float8</type>, <type>timestamp with time zone</type>, <type>timestamp without time zone</type>, <type>time without time zone</type>, <type>date</type>, <type>interval</type>, <type>oid</type>, and <type>money</type>. また、自然な距離のあるデータ型には、btree_gistは距離演算子<->を定義し、この演算子を使った最近接検索へのGiSTインデックスのサポートを提供します。 距離演算子はint2int4int8float4float8timestamp with time zonetimestamp without time zonetime without time zonedateintervaloidmoneyに提供されます。

This module is considered <quote>trusted</quote>, that is, it can be installed by non-superusers who have <literal>CREATE</literal> privilege on the current database. このモジュールはtrustedと見なされます。つまり、現在のデータベースに対してCREATE権限を持つ非スーパーユーザがインストールできます。

F.9.1. 使用例 #

<title>Example Usage</title>

Simple example using <literal>btree_gist</literal> instead of <literal>btree</literal>: btreeの代わりにbtree_gistを使った簡単な例

CREATE TABLE test (a int4);

&#45;- create index

-- インデックスの作成
CREATE INDEX testidx ON test USING GIST (a);

&#45;- query

-- 問い合わせ
SELECT * FROM test WHERE a < 10;

&#45;- nearest-neighbor search: find the ten entries closest to "42"

-- 最近接検索: "42"に一番近い10個のエントリを見つける
SELECT *, a <-> 42 AS dist FROM test ORDER BY a <-> 42 LIMIT 10;

Use an <link linkend="sql-createtable-exclude">exclusion constraint</link> to enforce the rule that a cage at a zoo can contain only one kind of animal: 動物園の一つの檻に1種類の動物しかいないというルールを強制するために排他制約を使います。

=> CREATE TABLE zoo (
  cage   INTEGER,
  animal TEXT,
  EXCLUDE USING GIST (cage WITH =, animal WITH <>)
);

=> INSERT INTO zoo VALUES(123, 'zebra');
INSERT 0 1
=> INSERT INTO zoo VALUES(123, 'zebra');
INSERT 0 1
=> INSERT INTO zoo VALUES(123, 'lion');
ERROR:  conflicting key value violates exclusion constraint "zoo_cage_animal_excl"
DETAIL:  Key (cage, animal)=(123, lion) conflicts with existing key (cage, animal)=(123, zebra).
=> INSERT INTO zoo VALUES(124, 'lion');
INSERT 0 1

F.9.2. 作者 #

<title>Authors</title>

Teodor Sigaev (<email>teodor@stack.net</email>), Oleg Bartunov (<email>oleg@sai.msu.su</email>), Janko Richter (<email>jankorichter@yahoo.de</email>), and Paul Jungwirth (<email>pj@illuminatedcomputing.com</email>). See <ulink url="http://www.sai.msu.su/~megera/postgres/gist/"></ulink> for additional information. Teodor Sigaev()、 Oleg Bartunov()、 Janko Richter ()、およびPaul Jungwirth ()。 追加情報はhttp://www.sai.msu.su/~megera/postgres/gist/を参照ください。