Purpose of Query
This page provides a SQL query to check the disk utilization of a particular schema on a Postgres database.
Applicable CAST Version
Release | Yes/No |
---|---|
8.3.x |
Applicable RDBMS
RDBMS | Yes/No |
---|---|
CSS3 | |
CSS4 |
Query for Postgres
Connect to the Postgres SQL database and run the below query, ( for getting more functional column name )
SELECT schema_name, pg_size_pretty(sum(table_size)::bigint) as schema_size FROM ( SELECT pg_catalog.pg_namespace.nspname as schema_name, pg_relation_size(pg_catalog.pg_class.oid) as table_size FROM pg_catalog.pg_class JOIN pg_catalog.pg_namespace ON relnamespace = pg_catalog.pg_namespace.oid ) t GROUP BY schema_name ORDER BY schema_name
Query result example
Query result interpretation
The query results in two columns, schema_name, and pg_size_pretty where it interprets:
schema_name: name of the schema
pg_size_pretty : size occupied by the schema