User Tools

Site Tools


posgres:space_usage

Grösse der DB

SELECT pg_size_pretty(pg_database_size('<dbname>')); 

Platzbedarf der Tabellen

select tablename, pg_size_pretty(s) from (select tablename, pg_relation_size(tablename::text) s 
from pg_tables where tableowner = '<username>') as ss order by s desc;

Platzbedarf der Indizes

select indexname, tablename, pg_size_pretty(s) from 
  (select tablename, indexname,pg_relation_size(indexname::text) s from pg_indexes) 
  as ss order by s desc;

Verhältnis Tables zu indices

select pg_size_pretty(sumind) "space index",  
       pg_size_pretty(sumtable) "space table", 
       round(sumind/sumtable, 3) "quotient" from  
  (select sum(pg_relation_size(indexname::text)) sumind from pg_indexes) ti,
  (select sum(pg_relation_size(tablename::text)) sumtable from pg_tables where tableowner = '<username>') tt;
posgres/space_usage.txt · Last modified: 2014/09/10 21:22 (external edit)