4 The catalog pg_class describes tables and other objects that have
5 columns or are otherwise similar to a table. This includes indexes (but
6 see also pg_index), sequences (but see also pg_sequence), views,
7 materialized views, composite types, and TOAST tables; see relkind.
8 Below, when we mean all of these kinds of objects we speak of
9 “relations”. Not all of pg_class's columns are meaningful for all
12 Table 52.11. pg_class Columns
24 Name of the table, index, view, etc.
26 relnamespace oid (references pg_namespace.oid)
28 The OID of the namespace that contains this relation
30 reltype oid (references pg_type.oid)
32 The OID of the data type that corresponds to this table's row type, if
33 any; zero for indexes, sequences, and toast tables, which have no
36 reloftype oid (references pg_type.oid)
38 For typed tables, the OID of the underlying composite type; zero for
41 relowner oid (references pg_authid.oid)
45 relam oid (references pg_am.oid)
47 The access method used to access this table or index. Not meaningful if
48 the relation is a sequence or has no on-disk file, except for
49 partitioned tables, where, if set, it takes precedence over
50 default_table_access_method when determining the access method to use
51 for partitions created when one is not specified in the creation
56 Name of the on-disk file of this relation; zero means this is a
57 “mapped” relation whose disk file name is determined by low-level state
59 reltablespace oid (references pg_tablespace.oid)
61 The tablespace in which this relation is stored. If zero, the
62 database's default tablespace is implied. Not meaningful if the
63 relation has no on-disk file, except for partitioned tables, where this
64 is the tablespace in which partitions will be created when one is not
65 specified in the creation command.
69 Size of the on-disk representation of this table in pages (of size
70 BLCKSZ). This is only an estimate used by the planner. It is updated by
71 VACUUM, ANALYZE, and a few DDL commands such as CREATE INDEX.
75 Number of live rows in the table. This is only an estimate used by the
76 planner. It is updated by VACUUM, ANALYZE, and a few DDL commands such
77 as CREATE INDEX. If the table has never yet been vacuumed or analyzed,
78 reltuples contains -1 indicating that the row count is unknown.
82 Number of pages that are marked all-visible in the table's visibility
83 map. This is only an estimate used by the planner. It is updated by
84 VACUUM, ANALYZE, and a few DDL commands such as CREATE INDEX.
88 Number of pages that are marked all-frozen in the table's visibility
89 map. This is only an estimate used for triggering autovacuums. It can
90 also be used along with relallvisible for scheduling manual vacuums and
91 tuning vacuum's freezing behavior. It is updated by VACUUM, ANALYZE,
92 and a few DDL commands such as CREATE INDEX.
94 reltoastrelid oid (references pg_class.oid)
96 OID of the TOAST table associated with this table, zero if none. The
97 TOAST table stores large attributes “out of line” in a secondary table.
101 True if this is a table and it has (or recently had) any indexes
105 True if this table is shared across all databases in the cluster. Only
106 certain system catalogs (such as pg_database) are shared.
110 p = permanent table/sequence, u = unlogged table/sequence, t =
111 temporary table/sequence
115 r = ordinary table, i = index, S = sequence, t = TOAST table, v = view,
116 m = materialized view, c = composite type, f = foreign table, p =
117 partitioned table, I = partitioned index
121 Number of user columns in the relation (system columns not counted).
122 There must be this many corresponding entries in pg_attribute. See also
127 Number of CHECK constraints on the table; see pg_constraint catalog
131 True if table has (or once had) rules; see pg_rewrite catalog
135 True if table has (or once had) triggers; see pg_trigger catalog
139 True if table or index has (or once had) any inheritance children or
144 True if table has row-level security enabled; see pg_policy catalog
146 relforcerowsecurity bool
148 True if row-level security (when enabled) will also apply to table
149 owner; see pg_policy catalog
153 True if relation is populated (this is true for all relations other
154 than some materialized views)
158 Columns used to form “replica identity” for rows: d = default (primary
159 key, if any), n = nothing, f = all columns, i = index with
160 indisreplident set (same as nothing if the index used has been dropped)
164 True if table or index is a partition
166 relrewrite oid (references pg_class.oid)
168 For new relations being written during a DDL operation that requires a
169 table rewrite, this contains the OID of the original relation;
170 otherwise zero. That state is only visible internally; this field
171 should never contain anything other than zero for a user-visible
176 All transaction IDs before this one have been replaced with a permanent
177 (“frozen”) transaction ID in this table. This is used to track whether
178 the table needs to be vacuumed in order to prevent transaction ID
179 wraparound or to allow pg_xact to be shrunk. Zero
180 (InvalidTransactionId) if the relation is not a table.
184 All multixact IDs before this one have been replaced by a transaction
185 ID in this table. This is used to track whether the table needs to be
186 vacuumed in order to prevent multixact ID wraparound or to allow
187 pg_multixact to be shrunk. Zero (InvalidMultiXactId) if the relation is
192 Access privileges; see Section 5.8 for details
196 Access-method-specific options, as “keyword=value” strings
198 relpartbound pg_node_tree
200 If table is a partition (see relispartition), internal representation
201 of the partition bound
203 Several of the Boolean flags in pg_class are maintained lazily: they
204 are guaranteed to be true if that's the correct state, but may not be
205 reset to false immediately when the condition is no longer true. For
206 example, relhasindex is set by CREATE INDEX, but it is never cleared by
207 DROP INDEX. Instead, VACUUM clears relhasindex if it finds the table
208 has no indexes. This arrangement avoids race conditions and improves