Contents
pg_partition_root()
A function returning a partitioned relation's root relation
pg_partition_root()
is a system function returning the top-most parent of the specified relation's partition hierarchy.
pg_partition_root()
was added in PostgreSQL 12.
Usage
pg_partition_root (regclass
) →regclass
Returns NULL
if the specified relation is not part of a partitioned table or index hierarchy.
Change history
- PostgreSQL 12
- added (commit 3677a0b2)
Examples
Assuming the partitioned table defined in the pg_partition_tree() example, pg_partition_root()
returns the following output:
postgres=# SELECT pg_partition_root('partition_test_6_10'); pg_partition_root ------------------- partition_test (1 row)
NULL
is returned if the relation is not a partitioned table:
postgres=# SELECT pg_partition_root('pg_class') IS NULL; ?column? ---------- t (1 row)
Executing pg_partition_root()
with the name of a non-existent relation:
postgres=# SELECT pg_partition_root('foo'); ERROR: relation "foo" does not exist LINE 1: SELECT pg_partition_root('foo');
References
- PostgreSQL documentation: Partitioning Information Functions