Operator Classes and Operator Families

11.9. Operator Classes and Operator Families

An index definition can specify an operator class for each column of an index.

CREATE INDEX name ON table (column opclass [sort options] [, ...]);

The operator class identifies the operators to be used by the index for that column. For example, a B-tree index on the type int4 would use the int4_ops class; this operator class includes comparison functions for values of type int4. In practice the default operator class for the column's data type is usually sufficient. The main reason for having operator classes is that for some data types, there could be more than one meaningful index behavior. For example, we might want to sort a complex-number data type either by absolute value or by real part. We could do this by defining two operator