我将从
mysql转到postgres,我在创建索引时遇到问题.
CREATE INDEX pointsloc ON table USING gist(point_col);
错误:数据类型点没有访问方法“gist”的默认运算符类
提示:您必须为索引指定运算符类,或者为数据类型定义默认运算符类.
我已经看到我需要为索引指定运算符类,可以使用不同的类,具体取决于您希望在列上使用的运算符的类型.我希望使用@>或〜来查找一个点是否在多边形内.
我如何指定运算符类?帮助请一定是一件简单的事情,但我很难过!
编辑
下面是我尝试向分支表添加索引的打印屏幕:
Table "public.branch" Column | Type | Modifiers ------------------+------------------+----------------------------------------------------- id | integer | not null default nextval('branch_id_seq'::regclass) name | character(120) | center_point_lat | double precision | center_point_lng | double precision | center_point | point | Indexes: "branch_pkey" PRIMARY KEY,btree (id) paul=# create index pt_idx on branch using gist (center_point); ERROR: data type point has no default operator class for access method "gist" HINT: You must specify an operator class for the index or define a default operator class for the data type.
我尝试时似乎工作正常:
test=# create table test (pt point); CREATE TABLE test=# create index pt_idx on test using gist (pt); CREATE INDEX
你确定你的point_col实际上是类型点吗?因为,如果它是一个varchar,那么在没有btree_gist contrib的情况下它确实会失败 – 即便如此它也不会非常有用.