Updated on 2024-06-03 GMT+08:00

PG_PARTITION

PG_PARTITION records all partitioned tables, table partitions, and index partitions in the database. Partitioned index information is not stored in the system catalog PG_PARTITION. The partitioned table does not have actual physical files. Therefore, pg_partition does not record information such as relfilenode, relpages, reltuples, reltoastrelid, and reltoastidxid.

Table 1 PG_PARTITION columns

Name

Type

Description

oid

oid

Row identifier (hidden attribute, which must be specified).

relname

name

Names of the partitioned tables, table partitions, TOAST tables on table partitions, and index partitions.

parttype

"char"

Object type.
  • 'r': partitioned table.
  • 'p': table partition.
  • 's': table subpartition.
  • 'x': index partition.

parentid

oid

  • OID of the partitioned table in PG_CLASS when the object is a partitioned table or a partition.
  • OID of the level-1 partition in PG_PARTITION when the object is a level-2 partition.
  • OID of the partitioned index when the object is an index partition.

rangenum

integer

Reserved column.

intervalnum

integer

Reserved column.

partstrategy

"char"

Partitioning policy of the partitioned table.
  • 'r': range partition.
  • 'i': interval partition.
  • 'l': list partition.
  • 'a': automatically extended list partition.
  • 'h': hash partition.
  • 'n': no partition policy. The object is not a table partition.

relfilenode

oid

Physical storage locations of the table partition, index partition, and TOAST table on the table partition.

reltablespace

oid

OID of the tablespace containing the table partition, index partition, and TOAST table on the table partition.

relpages

double precision

Statistics: numbers of data pages of the table partition and index partition.

reltuples

double precision

Statistics: numbers of tuples of the table partition and index partition.

relallvisible

integer

Statistics: number of visible data pages of the table partition and index partition.

reltoastrelid

oid

OID of the TOAST table corresponding to the table partition.

reltoastidxid

oid

OID of the TOAST table index corresponding to the table partition.

indextblid

oid

OID of the table partition corresponding to the index partition.

indisusable

Boolean

Specifies whether the index partition is available.

relfrozenxid

xid32

Frozen transaction ID.

To ensure forward compatibility, this column is reserved. The relfrozenxid64 column is added to record the information.

intspnum

integer

Number of tablespaces that the interval partition belongs to.

partkey

int2vector

Column number of the partition key.

intervaltablespace

oidvector

Tablespace that the interval partition belongs to. Interval partitions fall in the tablespaces in the round-robin manner.

interval

text[]

Interval value of the interval partition.

boundaries

text[]

Upper boundary of the range partition and interval partition.

transit

text[]

Transit of the interval partition.

reloptions

text[]

Storage attribute of a partition used for collecting online scale-out information. Same as pg_class.reloptions, it is expressed in a string in the format of keyword=value.

relfrozenxid64

xid

Frozen transaction ID.

relminmxid

xid

Frozen multi-transaction ID.

partitionno

integer

Used for maintaining the partition map of a partitioned table.
  • If the object is a partition, this field indicates the partition ID, which starts from 1 in ascending order.
  • If the object is a partitioned table, this field indicates the maximum partition ID and a negative value is used for special meaning. The value increases with the DDL syntax of some partitions.
  • If the object is of other types, this field is null and has no meaning.

partitionno is a permanent auto-increment column, which can be reset or reclaimed by using the syntax ALTER TABLE t_name RESET PARTITION.

subpartitionno

integer

Used for maintaining the map of level-2 partitions in a partitioned table.
  • If the object is a level-2 partition, this field indicates the level-2 partition ID, which starts from 1 in ascending order.
  • If the object is a level-1 partition in a level-2 partitioned table, this field indicates the maximum level-2 partition ID and a negative value is used for special meaning. This value increases with the DDL syntax of some partitions.
  • If the object is of other types, this field is null and has no meaning.

subpartitionno is a permanent auto-increment column, which can be reset or reclaimed by using the syntax ALTER TABLE t_name RESET PARTITION.