Postgresql 中文操作指南

F.8. btree_gin — GIN operator classes with B-tree behavior #

btree_gin 提供了 GIN 操作器类,它们为数据类型 int2int4int8float4float8timestamp with time zonetimestamp without time zonetime with time zonetime without time zonedateintervaloidmoney"char"varchartextbyteabitvarbitmacaddrmacaddr8inetcidruuidnameboolbpchar 和所有 enum 类型实现类似 B 树的行为。

btree_gin provides GIN operator classes that implement B-tree equivalent behavior for the data types int2, int4, int8, float4, float8, timestamp with time zone, timestamp without time zone, time with time zone, time without time zone, date, interval, oid, money, "char", varchar, text, bytea, bit, varbit, macaddr, macaddr8, inet, cidr, uuid, name, bool, bpchar, and all enum types.

一般来说,这些操作器类的性能不会超过等效的标准 B 树索引方法,并且它们缺少标准 B 树代码的一项主要功能:强制唯一性。但是,它们对于 GIN 测试和作为开发其他 GIN 操作器类的基础很有用。此外,对于测试可 GIN 索引列和可 B 树索引列的查询,创建一个多列 GIN 索引(使用这些操作器类之一)可能比创建必须通过位图 AND 连接的两个单独索引更有效。

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 are useful for GIN testing and as a base for developing other GIN operator classes. Also, for queries that test both a GIN-indexable column and a B-tree-indexable column, it might be more efficient to create a multicolumn GIN index that uses one of these operator classes than to create two separate indexes that would have to be combined via bitmap ANDing.

此模块被认为是“受信任的”,也就是说,它可以由在当前数据库上具有 CREATE 权限的非超级用户安装。

This module is considered “trusted”, that is, it can be installed by non-superusers who have CREATE privilege on the current database.

F.8.1. Example Usage #

CREATE TABLE test (a int4);
-- create index
CREATE INDEX testidx ON test USING GIN (a);
-- query
SELECT * FROM test WHERE a < 10;

F.8.2. Authors #

Teodor Sigaev ( < link:mailto:teodor@stack.net[teodor@stack.net]> ) 和 Oleg Bartunov ( < link:mailto:oleg@sai.msu.su[oleg@sai.msu.su]> )。有关更多信息,请访问链接: http://www.sai.msu.su/ megera/oddmuse/index.cgi/Gin[http://www.sai.msu.su/ megera/oddmuse/index.cgi/Gin]。