]> begriffs open source - ai-pg/blob - full-docs/txt/catalog-pg-class.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / catalog-pg-class.txt
1
2 52.11. pg_class #
3
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
10    relation kinds.
11
12    Table 52.11. pg_class Columns
13
14    Column Type
15
16    Description
17
18    oid oid
19
20    Row identifier
21
22    relname name
23
24    Name of the table, index, view, etc.
25
26    relnamespace oid (references pg_namespace.oid)
27
28    The OID of the namespace that contains this relation
29
30    reltype oid (references pg_type.oid)
31
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
34    pg_type entry
35
36    reloftype oid (references pg_type.oid)
37
38    For typed tables, the OID of the underlying composite type; zero for
39    all other relations
40
41    relowner oid (references pg_authid.oid)
42
43    Owner of the relation
44
45    relam oid (references pg_am.oid)
46
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
52    command.
53
54    relfilenode oid
55
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
58
59    reltablespace oid (references pg_tablespace.oid)
60
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.
66
67    relpages int4
68
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.
72
73    reltuples float4
74
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.
79
80    relallvisible int4
81
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.
85
86    relallfrozen int4
87
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.
93
94    reltoastrelid oid (references pg_class.oid)
95
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.
98
99    relhasindex bool
100
101    True if this is a table and it has (or recently had) any indexes
102
103    relisshared bool
104
105    True if this table is shared across all databases in the cluster. Only
106    certain system catalogs (such as pg_database) are shared.
107
108    relpersistence char
109
110    p = permanent table/sequence, u = unlogged table/sequence, t =
111    temporary table/sequence
112
113    relkind char
114
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
118
119    relnatts int2
120
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
123    pg_attribute.attnum.
124
125    relchecks int2
126
127    Number of CHECK constraints on the table; see pg_constraint catalog
128
129    relhasrules bool
130
131    True if table has (or once had) rules; see pg_rewrite catalog
132
133    relhastriggers bool
134
135    True if table has (or once had) triggers; see pg_trigger catalog
136
137    relhassubclass bool
138
139    True if table or index has (or once had) any inheritance children or
140    partitions
141
142    relrowsecurity bool
143
144    True if table has row-level security enabled; see pg_policy catalog
145
146    relforcerowsecurity bool
147
148    True if row-level security (when enabled) will also apply to table
149    owner; see pg_policy catalog
150
151    relispopulated bool
152
153    True if relation is populated (this is true for all relations other
154    than some materialized views)
155
156    relreplident char
157
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)
161
162    relispartition bool
163
164    True if table or index is a partition
165
166    relrewrite oid (references pg_class.oid)
167
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
172    relation.
173
174    relfrozenxid xid
175
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.
181
182    relminmxid xid
183
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
188    not a table.
189
190    relacl aclitem[]
191
192    Access privileges; see Section 5.8 for details
193
194    reloptions text[]
195
196    Access-method-specific options, as “keyword=value” strings
197
198    relpartbound pg_node_tree
199
200    If table is a partition (see relispartition), internal representation
201    of the partition bound
202
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
209    concurrency.