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

PG_CLASS

PG_CLASS stores information about all built-in system catalog objects in the database and their relationships.

Table 1 PG_CLASS columns

Column

Type

Description

oid

oid

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

relname

name

Name of an object, such as a table, index, or view.

relnamespace

oid

OID of the namespace containing the relation.

reltype

oid

Data type corresponding to the row type of the table (zero for indexes since they do not have a pg_type entry).

reloftype

oid

OID of the composite type. The value 0 indicates other types.

relowner

oid

Owner of the relation.

relam

oid

Access method used if the row represents an index (for example, B-tree, hash).

relfilenode

oid

File name of the relation's storage on disk. The value is 0 if there is not one.

reltablespace

oid

Tablespace where the relation resides. The value 0 means using the database's default tablespace. Meaningless if the relation lacks disk files.

relpages

double precision

Approximate size of the table on disk measured in blocks (of size BLCKSZ), utilized by the optimizer.

reltuples

double precision

Estimated number of rows in the table, used by the optimizer.

relallvisible

integer

Count of fully visible pages within the table, This column is used by the optimizer for optimizing SQL execution. It is updated by VACUUM, ANALYZE, and a few DDL statements such as CREATE INDEX.

reltoastrelid

oid

OID of the TOAST table associated with the table. If there is no TOAST table, the value is 0.

A TOAST table stores oversized columns offline in a secondary table.

reltoastidxid

oid

Index OID specific to a TOAST table. Otherwise, set it to 0.

reldeltarelid

oid

OID of a delta table.

Delta tables are attached to column-store tables, storing the trailing data generated during data import.

reldeltaidx

oid

OID of the index table for a Delta table.

relcudescrelid

oid

OID of a CU description table.

CU description tables (Desc tables) belong to column-store tables. They control the visibility of data stored in the table directory.

relcudescidx

oid

OID of the index table for the CU description table.

relhasindex

Boolean

Its value is true if this column is a table and has (or recently had) at least one index.

It is set by CREATE INDEX but is not immediately cleared by DROP INDEX. If the VACUUM process detects that a table has no index, it clears the relhasindex column and sets the value to false.

relisshared

Boolean

The value is true if the table is shared across all databases in the cluster. Only certain system catalogs (such as pg_database) are shared.

relpersistence

"char"

  • p indicates a permanent table.
  • u indicates an unlogged table.
  • t indicates a temporary table.

relkind

"char"

  • r indicates an ordinary table.
  • i indicates an index.
  • S indicates a sequence.
  • v indicates a view.
  • c indicates a composite type.
  • t indicates a TOAST table.
  • f indicates a foreign table.
  • m indicates a materialized view.

relnatts

smallint

Number of user columns (excluding system columns) in a relation. Corresponding rows must exist in pg_attribute.

relchecks

smallint

Number of check constraints on the table.

relhasoids

Boolean

If an OID is generated for each row in the relation, the value is true.

relhaspkey

Boolean

If the table has (or had) a primary key, the value is true.

relhasrules

Boolean

If the table has rules, the value is true.

relhastriggers

Boolean

If the table has (or had) triggers, the value is true.

relhassubclass

Boolean

If the table has (or had) any inherited child tables, the value is true.

relcmprs

tinyint

Whether table compression is enabled. Note that compression is triggered only when batch insertion occurs. Ordinary CRUD operations will not trigger compression.

  • 0: indicates tables that do not support compression (primarily system catalogs, which do not allow modifications to their compression attributes).
  • 1: indicates that the compression feature of the table data is set to NOCOMPRESS or no specific keyword is provided.
  • 2: indicates that the compression feature of the table data is set to COMPRESS.

relhasclusterkey

Boolean

Whether partial cluster storage is available.

relrowmovement

Boolean

Whether row movement is allowed when updating a partitioned table. Options:

  • true: Row movement is allowed.
  • false: Row movement is not allowed.

parttype

"char"

Whether the table or index has the properties of a partitioned table.

  • p indicates that it has the properties of a partitioned table.
  • n indicates that it does not has the properties of a partitioned table.
  • v indicates that the table is an HDFS Value-partitioned table.

relfrozenxid

xid32

All transaction IDs in this table prior to this point have been replaced with a fixed ("frozen") transaction ID. This column is used to track whether the table requires cleaning to prevent transaction ID overlap (or to allow shrinking of pg_clog). If the relation is not a table, the value is 0 (InvalidTransactionId).

For forward compatibility, this column is retained, and relfrozenxid64 is added to record this information.

relacl

aclitem[]

Access permissions.

The query result displays in the following form:

1
rolename=xxxx/yyyy  -- Permissions granted to a role.
1
=xxxx/yyyy  -- Public permissions granted

xxxx indicates the granted permissions, and yyyy indicates the role to whom the permissions are granted. For detailed parameter descriptions of permissions, refer to Table 2.

reloptions

text[]

Specific access method options, represented in the form of keyword=value.

relfrozenxid64

xid

All transaction IDs in this table prior to this point have been replaced with a fixed ("frozen") transaction ID. This column is used to track whether the table requires cleaning to prevent transaction ID overlap (or to allow shrinking of pg_clog). If the relation is not a table, the value is 0 (InvalidTransactionId).

Table 2 Parameter descriptions for permissions

Parameter

Description

r

SELECT (read)

w

UPDATE (write)

a

INSERT (insert)

d

DELETE

D

TRUNCATE

x

REFERENCES

t

TRIGGER

X

EXECUTE

U

USAGE

C

CREATE

c

CONNECT

T

TEMPORARY

A

ANALYZE|ANALYSE

L

ALTER

P

DROP

v

VACUUM

arwdDxtA, vLP

ALL PRIVILEGES (for tables)

*

Authorization options for preceding permissions