Updated on 2025-08-25 GMT+08:00

PG_OPCLASS

PG_OPCLASS defines index access method operator classes.

Each operator class defines the semantics of index columns for a specific data type and a specific index access method. Essentially, an operator class specifies that a particular operator family is applicable to a specific indexable column data type. The set of operators in the family that are actually usable by the indexed column are those that accept the column's data type as their left-hand input.

Table 1 PG_OPCLASS columns

Column

Type

Reference

Description

oid

oid

-

Row identifier (a hidden attribute that is only shown upon explicit selection).

opcmethod

oid

PG_AM.oid

Index access method the operator class belongs to.

opcname

name

-

Name of the operator class.

opcnamespace

oid

PG_NAMESPACE.oid

Namespace the operator class belongs to.

opcowner

oid

PG_AUTHID.oid

Owner of the operator class.

opcfamily

oid

PG_OPFAMILY.oid

Operator family containing this operator class.

opcintype

oid

PG_TYPE.oid

Data type of the operator class index.

opcdefault

Boolean

-

The value is true if the operator class is the default for opcintype.

opckeytype

oid

PG_TYPE.oid

Type of the index data. If it is the same as that of opcintype, the value is 0.

The opcmethod of an operator class must match the opfmethod of the operator family that contains it. Similarly, for any given combination of opcmethod and opcintype, there cannot be more than one PG_OPCLASS row with opcdefault set to true.