0

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?

1 Answer 1

2

The GIN index doesn't just require a custom operator. It requires a whole family of operators. Basically you need to:

  1. Consult the documentation regarding GIN opclasses.

  2. Write a set of IMMUTABLE functions to handle those.

  3. Write a set of operators based on those functions.

  4. 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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Chris. This dawned on me after digging deep into online documentation, and when no one answered.
would you please expand a bit on point number 4? I have asked the question here: stackoverflow.com/q/34407438/1319179

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.