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

  • Mastering PostgreSQL 9.6
  • Hans Jurgen Schonig
  • 162字
  • 2021-07-09 19:57:20

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.

主站蜘蛛池模板: 大化| 武宁县| 长宁区| 科尔| 吉隆县| 稻城县| 泗洪县| 始兴县| 浙江省| 嵩明县| 玉山县| 湘西| 绍兴县| 临汾市| 聂荣县| 锡林浩特市| 安丘市| 大化| 财经| 汉源县| 丽江市| 岳普湖县| 泾阳县| 饶阳县| 抚远县| 南乐县| 达尔| 潼关县| 浦北县| 都江堰市| 大方县| 汶川县| 九江县| 侯马市| 同仁县| 民乐县| 沅陵县| 古浪县| 佛坪县| 辰溪县| 丰原市|