I need to find size of a table in posgreSQL. I am using following command but it is giving me 0 as an output. Could you please inform me how can I get the size of a table?
INPUT:
select pg_relation_size('tableName');
OUTPUT:
pg_relation_size
0
(1 row)
I know this is ancient but I just ran into the same issue. It was due to the fact that the table is a partitioned one, so technically it doesn't have a real size. To get the combined size of all the partitions, check out this question.
Or you could simply make use of the inheritance catalog like:
SELECT count(*) AS child_amount, pg_size_pretty(sum(pg_relation_size(inhrelid::regclass))) AS child_size
FROM pg_inherits
WHERE inhparent='tableName'::regclass;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With