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

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

主站蜘蛛池模板: 肥东县| 辉南县| 娄底市| 册亨县| 仁布县| 个旧市| 那坡县| 平和县| 平湖市| 观塘区| 昌宁县| 驻马店市| 喀喇沁旗| 惠水县| 延寿县| 沙田区| 潮安县| 广州市| 集贤县| 阳新县| 金阳县| 大洼县| 电白县| 视频| 涡阳县| 岑巩县| 类乌齐县| 奉贤区| 信宜市| 米林县| 大邑县| 晋宁县| 平谷区| 于田县| 施甸县| 渝中区| 股票| 湾仔区| 彩票| 博客| 天长市|