After partitioning a table in Postgres, it's nice to see how the data is distributed across all the partitions. The following query will generate the count of all partitioned tables.
Make sure to modify the parent table name to meet your needs.
SELECT child.relname AS partition, n_live_tup AS count
FROM pg_inherits AS i
JOIN pg_class AS child ON child.oid = i.inhrelid
JOIN pg_stat_user_tables AS stat ON stat.relid = child.oid
WHERE i.inhparent = 'photo_licenses'::regclass;
partition | count
------------------+--------
photo_licenses_12 | 800851
photo_licenses_13 | 799392
photo_licenses_17 | 799514
photo_licenses_14 | 800551
photo_licenses_15 | 800597
photo_licenses_16 | 798680
photo_licenses_18 | 798678
photo_licenses_19 | 800969
photo_licenses_1 | 800695
photo_licenses_2 | 801663
photo_licenses_3 | 800210
photo_licenses_4 | 800526
photo_licenses_5 | 799994
photo_licenses_6 | 799539
photo_licenses_9 | 798588
photo_licenses_7 | 799069
photo_licenses_8 | 800763
photo_licenses_10 | 800819
photo_licenses_11 | 799641
photo_licenses_20 | 800020
photo_licenses_21 | 800410
photo_licenses_22 | 798471
photo_licenses_23 | 799807
photo_licenses_24 | 800609
photo_licenses_25 | 799954
(25 rows)
Wow. This is awesome! Thanks. Pretty much what I was looking for.
Well, I just so happen there is one here that adresses your query :)
Have a look at
https://github.com/jtorral/DockerPgHa
It spins up postgres, patroni and pgbackrest.
The best feature is the genCompose script which creates a docker-compose file for you based on your supplied input.
This repo needs some enhancements but it is a good start.