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

  • Mastering PostgreSQL 12
  • Hans Jürgen Sch?nig
  • 183字
  • 2021-08-20 10:00:28

Creating operator classes

Finally, all the components are in place, and it is possible to create the operator class that's 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 to OPERATOR 1<# means that strategy 1 will use the <# operator. Finally, the 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 before: 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, and will instead decide on the default operator class.

主站蜘蛛池模板: 涿鹿县| 休宁县| 汉川市| 佛山市| 汉中市| 彭州市| 彩票| 阿拉善左旗| 伊通| 博爱县| 贵州省| 阳春市| 讷河市| 合山市| 嘉鱼县| 蚌埠市| 车致| 云南省| 通城县| 四会市| 临澧县| 阿勒泰市| 东安县| 荔波县| 皮山县| 河津市| 石台县| 钦州市| 台北县| 万全县| 曲周县| 页游| 静宁县| 高青县| 抚宁县| 蒙阴县| 句容市| 沧源| 曲靖市| 本溪| 赤水市|