i found this query on how to check the size of a table in Postgres
select pg_size_pretty(pg_relation_size('the_table'));
I want to get the size from multiple tables. My database has this kind of table name:
tblresource_01012014
tblresource_02012014
tblresource_03012014
...
It has date on its name. i want to get the size for a specific month. something like,
select pg_size_pretty(pg_relation_size('tblresource_**012014'));
Absolutely this query is wrong. anybody knows what are the right query to execute
MY SOLUTION
Hey guys, for now i have a solution for this which is quite simple but i wont say it as a good answer though cause it might only works for my case. and doesn't fully meet my goal. here how i do it.
select table_name, pg_size_pretty(pg_relation_size(table_name))
from information_schema.tables
where table_name like 'tblresource_%012014'
3条答案
按热度按时间erhoui1w1#
You could generate the values using a query:
9rbhqvlz2#
sqlfiddle demo
You can wrap above select into a function like below
function call :
ukxgm1gy3#
Following query will returns sum of two tables with union,split_part and sum functions.