pg_class

The system catalog table pg_class catalogs tables and most everything else that has columns or is otherwise similar to a table (also known as relations). This includes indexes (see also pg_index), sequences, views, composite types, and TOAST tables. Not all columns are meaningful for all relation types.

Table 1. pg_catalog.pg_class

columntypereferencesdescription
relnamename Name of the table, index, view, etc.
relnamespaceoidpg_namespace.oidThe OID of the namespace (schema) that contains this relation
reltypeoidpg_type.oidThe OID of the data type that corresponds to this table’s row type, if any (zero for indexes, which have no pg_type entry)
relowneroidpg_authid.oidOwner of the relation
relamoidpg_am.oidIf this is an index, the access method used (B-tree, Bitmap, hash, etc.)
relfilenodeoid Name of the on-disk file of this relation; 0 if none.
reltablespaceoidpg_tablespace.oidThe tablespace in which this relation is stored. If zero, the database’s default tablespace is implied. (Not meaningful if the relation has no on-disk file.)
relpagesinteger Size of the on-disk representation of this table in pages (of 32K each). This is only an estimate used by the planner. It is updated by ANALYZE, and a few DDL commands.
reltuplesreal Number of rows in the table. This is only an estimate used by the planner. It is updated by VACUUM, ANALYZE, and a few DDL commands.
reltoastrelidoidpg_class.oidOID of the TOAST table associated with this table, 0 if none. The TOAST table stores large attributes “out of line” in a secondary table.
reltoastidxidoidpg_class.oidFor a TOAST table, the OID of its index. 0 if not a TOAST table.
relaosegidxidoid Deprecated.
relaosegrelidoid Deprecated.
relhasindexboolean True if this is a table and it has (or recently had) any indexes. This is set by CREATE INDEX, but not cleared immediately by DROP INDEX. VACUUM will clear if it finds the table has no indexes.
relissharedboolean True if this table is shared across all databases in the system. Only certain system catalog tables are shared.
relkindchar The type of object

r = heap table, i = index, S = sequence, v = view, c = composite type, t = TOAST value, c = composite type, u = uncataloged temporary heap table

relstoragechar The storage mode of a table

a = append-only, h = heap, p = append-only parquet, v = virtual, x= external table.

relnattssmallint Number of user columns in the relation (system columns not counted). There must be this many corresponding entries in pg_attribute.
relcheckssmallint Number of check constraints on the table.
reltriggerssmallint Number of triggers on the table.
relukeyssmallint Unused
relfkeyssmallint Unused
relrefssmallint Unused
relhasoidsboolean True if an OID is generated for each row of the relation.
relhaspkeyboolean True if the table once had a primary key.
relhasrulesboolean True if table has rules.
relhassubclassboolean True if table has (or once had) any inheritance children.
relfrozenxidxid All transaction IDs before this one have been replaced with a permanent (frozen) transaction ID in this table. This is used to track whether the table needs to be vacuumed in order to prevent transaction ID wraparound or to allow pg_clog to be shrunk. Zero (InvalidTransactionId) if the relation is not a table.
relaclaclitem[] Access privileges assigned by GRANT and REVOKE.
reloptionstext[] Access-method-specific options, as “keyword=value” strings.