Postgres create an index

I am switching from mysql to postgres and I am having trouble creating an index.

CREATE INDEX pointsloc ON table USING gist (point_col);

This is the answer I am returning:

ERROR: the data type point does not have a default operator class for the access method "gist" TIP. You must specify an operator class for the index or define a default operator class for the data type.

I saw that I need to specify an operator class for the index, different classes can be used depending on the type of operators that you want to use in the column. I want to use @> or ~ to find if the point is inside the polygon.

How to specify an operator class? help, please, should be simple, but I'm at a standstill!

EDIT

The following is a print screen that is trying to add an index to the branch table:

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. 
+6
source share
1 answer

It seems to work fine when I try:

 test=# create table test (pt point); CREATE TABLE test=# create index pt_idx on test using gist (pt); CREATE INDEX 

Are you sure your point_col is of type point ? Because if it is varchar, then it will be really terrible to fail without the btree_gist contrib - and even then it will not be very useful.

+3
source

Source: https://habr.com/ru/post/892439/


All Articles