Reputation: 18239
I have the following custom type:
CREATE TYPE param_range AS (
param smallint,
range int4range
);
The following table:
CREATE TABLE test4
(
id serial NOT NULL,
geo point,
ext param_range[]
)
The following indexes:
CREATE INDEX ix_test4_geo ON test4 USING GIST ((geo));
CREATE INDEX ix_test4_ext on test4 USING GIN (ext);
The GIN index requires an operator / function for the custom type. How do I do this?
Upvotes: 0
Views: 416
Reputation: 26464
The GIN index doesn't just require a custom operator. It requires a whole family of operators. Basically you need to:
Consult the documentation regarding GIN opclasses.
Write a set of IMMUTABLE functions to handle those.
Write a set of operators based on those functions.
Tie those together in a custom operator class.
This isn't a simple, small amount of work. It requires a fair bit of though (what does "overlap" mean in the context of your type?" and so you need to expect to spend a fair bit of time in the design phase.
Basically if you want GIST/GIN support you are designing a custom type not just for storage but for operational purposes. This is a project.
Upvotes: 2