Топ-100
top of page
Волнистый абстрактный фон
CerebroSQL

PostgreSQL DB schema size percentage

The node displays information about the size of all objects in the schema, as well as the percentage of the schema size from the size of the entire database  PostgreSQL

PostgreSQL percent size schema
Request

SELECT pg_size_pretty(sum(table_size)::bigint) as "disk_space", 
      round((sum(table_size) / pg_database_size(current_database())) * 100) || '%' as "percent"
FROM (
     SELECT n.nspname as schema_name,
            pg_relation_size(c.oid) as table_size
     FROM   pg_catalog.pg_class c  
         JOIN pg_catalog.pg_namespace n
             ON c.relnamespace = n.oid 
     WHERE n.nspname = $$SCHEMANAME
) t 

bottom of page