Skip to main content
Version: 0.9.3

3.23. Operator classes

Operator classes define how a specific data type can be handled by indexes. This kind of object specifies a set of elements composed of operators, functions or storage modes that will fill a particular role or strategy when dealing with the data type combined with the index access method.

AttributeDescription
IndexingIndex access method used by the operator class. Possible values are btree, gin, gist, hash, spgist and brin.
Default ClassIndicates that the operator class is the default for the specified data type and index access method.
Operator FamilyDefines the operator family in which the operator class will be included. Details about operator families can be seen in the next section Operator families.
Data TypeData type in which operator class works.
ElementsThe group of fields that is is used to configure the operator class elements. These objects are detailed in the next subsection.

3.20.1. Operator class elements

Operator class elements are the small unit of an operator class. In order to create a valid operator class at least one element must exist. These objects can be constructed using an operator, function, or storage data type as detailed in the table below.

AttributeDescription
Element TypeType of the current element. It can be: Operator, Function or Storage.
OperatorIndicates the operator to be associated with the current element.
Operator FamilyDefines the btree operator family that specifies the sorting mode of an ordering operator. This attribute is used only when you want to create an element with data sorting properties.
FunctionDefines the function used as the index method support for the operator class.
Storage TypeSpecifies the data type that is in fact stored in the index. Generally, this is the same as the column data type. But there are some index access methods (like GiST and GIN) that allow this type to be overridden.
Support / StrategyWhen the element being configured uses an operator this attribute is the index method's strategy number. Now, when the element is using a function this is the index method's support procedure number. The value specified here is defined by each index access method used.

References​

Operator class DDL

https://www.postgresql.org/docs/current/static/sql-createopclass.html



More about operator classes

https://www.postgresql.org/docs/current/static/xindex.html