0

i check partition information from pg_partition,

select 
relname,
parttype,
parentid,
rangenum,
interval,
boundaries
from pg_partition where parttype='p';

the problem is: how to know where these partitions comes from,

tonyibm
  • 581
  • 2
  • 8
  • 24
  • 1
    There is no [system table](https://www.postgresql.org/docs/current/catalogs.html) `pg_partition` in Postgres –  Jul 21 '19 at 06:49

1 Answers1

1

If you're using greenplum, pg_partitions has a tablename column. See This answer

For Postgres, the name of the table that stores partition info is pg_partitioned_table

For table details that contain partitions, you may simple query pg_class as in this answer

select c.relnamespace::regnamespace::text as schema,
       c.relname as table_name, 
       pg_get_partkeydef(c.oid) as partition_key
from   pg_class c
where  c.relkind = 'p';

Here's a demo

If you want all the information of partition and their tables, you may combine the 2 tables as in this answer

Kaushik Nayak
  • 30,772
  • 5
  • 32
  • 45