I am running out of space on my default tablespace.
SELECT pg_size_pretty(pg_tablespace_size('pg_default'));
89 GB
(1 row)
However, if I calculate the pg_relation_size of all tables in this tablespace i only get 16GB
select pg_size_pretty(sum(sz))
from (
select *,(pg_total_relation_size(tablename::varchar)) as sz
from pg_tables
where tablespace is null
and tablename not like 'pg_%'
and schemaname != 'information_schema'
) as foo;
16 GB
(1 row)
So where is the rest?
I do calculate the index+data
oidtopg_total_relation_sizeotherwise this will give wrong results if you have the same table name in different schemas. You might also want to check the queries from here: wiki.postgresql.org/wiki/Disk_Usage