I want to list all the partitions created by dynamic triggers in PostgreSQL 9.1.
I was able to generate a count of partitions using this related answer by Frank Heikens.
I have a table foo with an insert trigger that creates foo_1, foo_2 etc. dynamically. The partition for insert is chosen based on the primary key id, a range based partitioning.
Is it possible to display all partitions currently in place for table foo?
relispartitionflag on thepg_classtable that you could reference but in practice if you try to inherit from a partitioned table then you get the message "cannot inherit from partitioned table". So if you know the table is partitioned then you would only get its partitions. If you wanted to verify that the parent is a partitioned table then you could addparent.relkind = 'p'to the where clause. – bygrace Dec 05 '23 at 19:17