Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all partition tables "inheriting" from master table

Say I have a table, "foo", with partition tables "foo1", "foo2", and "foo3". But at the current moment all I know is there are parition tables which inherit from table "foo". How can I find that foo has 3 partitions, foo1, foo2, and foo3?

like image 488
danjuggler Avatar asked Oct 20 '25 11:10

danjuggler


1 Answers

Starting with Postgres 12, there is a built-in function:

select *
from  pg_partition_tree('the_table'::regclass)
where parentrelid is not null;

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!