Creating operator classes

Finally, all components are in place and it is finally possible to create the operator class needed by the index:

CREATE OPERATOR CLASS sva_special_ops FOR TYPE text USING btree AS    OPERATOR 1 <# ,    OPERATOR 2 <=# ,    OPERATOR 3 = ,    OPERATOR 4 >=# ,    OPERATOR 5 ># ,    FUNCTION 1 si_same(text, text);

The CREATE OPERATOR CLASS command connects strategies and operators OPERATOR 1.

<# means that strategy 1 will use the <# operator. Finally, the _same function is connected with the operator class.

Note that the operator class has a name and that it has been explicitly defined to work with b-trees. The operator class can already be used during index creation:

CREATE INDEX idx_special ON t_sva (sva sva_special_ops);

Creating ...

Get Mastering PostgreSQL 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.