SELECT
child.oid::REGCLASS AS partition_name,
COALESCE(partition_tablespace.spcname, 'pg_default')
AS partition_tablespace,
child_index.oid::REGCLASS AS index_name,
COALESCE(index_tablespace.spcname, 'pg_default')
AS index_tablespace
FROM pg_inherits AS inheritance
JOIN pg_class AS child
ON child.oid = inheritance.inhrelid
LEFT JOIN pg_tablespace AS partition_tablespace
ON partition_tablespace.oid = child.reltablespace
LEFT JOIN pg_index AS index_metadata
ON index_metadata.indrelid = child.oid
LEFT JOIN pg_class AS child_index
ON child_index.oid = index_metadata.indexrelid
LEFT JOIN pg_tablespace AS index_tablespace
ON index_tablespace.oid = child_index.reltablespace
WHERE inheritance.inhparent =
'public.events_region_a'::REGCLASS
ORDER BY
partition_name,
index_name;