官术网_书友最值得收藏!

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 an index works in a slightly different way than previously: sva sva_special_ops means that the sva column is indexed using the sva_special_ops operator class. If sva_special_ops is not explicitly used, then PostgreSQL will not go for our special sort order but decide on the default operator class.

主站蜘蛛池模板: 禄丰县| 潼关县| 建瓯市| 濉溪县| 鹿邑县| 金寨县| 安国市| 汉寿县| 侯马市| 平舆县| 珲春市| 元谋县| 界首市| 大理市| 印江| 遂溪县| 靖州| 锡林浩特市| 大城县| 聊城市| 都江堰市| 柏乡县| 大同县| 怀仁县| 黔江区| 弥勒县| 武威市| 广汉市| 汕尾市| 宝应县| 松溪县| 井陉县| 鸡泽县| 扎兰屯市| 杭锦旗| 迁西县| 芦山县| 沈丘县| 沁源县| 获嘉县| 四子王旗|