使用带bigint列的postgresql gin或gist索引

the*_*erg 7 postgresql bigint

我试图在bigint列上创建gin索引并收到错误(PostgreSQL 9.1.9/Debian 7).

CREATE TABLE test (id bigint CONSTRAINT test_pkey PRIMARY KEY, field bigint);

CREATE INDEX idx_test_field ON test using GIN(field);

ERROR:  data type bigint has no default operator class for access method "gin"
HINT:  You must specify an operator class for the index or define a default operator class for the data type.
Run Code Online (Sandbox Code Playgroud)

对于int8杜松子酒,gist索引没有默认支持吗?

Cra*_*ger 15

通常没有理由在基本类型上创建GiST或GIN索引.

如果你确实需要这个 - 比如说,如果你想要一个包含一些基本类型和一些更复杂的GiST/GIN-only索引类型的复合索引 - 那么你将需要btree_gist或者btree_gin模块.

CREATE EXTENSION btree_gin;
Run Code Online (Sandbox Code Playgroud)