Re: How to identify all storage in a schema

From: "Campbell, Lance" <lance(at)illinois(dot)edu>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: How to identify all storage in a schema
Date: 2015-01-14 16:38:36
Message-ID: B75CD08C73BD3543B97E4EF3964B7D701FD5D776@CITESMBX1.ad.uillinois.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Fantastic! Thanks so much for the query.

Thanks,

Lance Campbell
Software Architect
Web Services at Public Affairs
217-333-0382

-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org [mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Thomas Kellerer
Sent: Wednesday, January 14, 2015 10:11 AM
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] How to identify all storage in a schema

Campbell, Lance schrieb am 14.01.2015 um 16:56:
> PostgreSQL 9.3
> Is there a query one can run that will give you a total storage for all objects (tables, indexes, etc) associated with a particular schema?
>
> Thanks for your assistance.

select table_schema,
sum(pg_total_relation_size(table_schema|| '.' ||table_name))
from information_schema.tables
where table_schema not in ('information_schema', 'pg_catalog')
group by table_schema;

Of for just a single schema:

select sum(pg_total_relation_size(table_schema|| '.' ||table_name))
from information_schema.tables
where table_schema = 'foobar';

There are other functions to retrieve the table or database sizes:

http://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT

Thomas

--
Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org) To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Eduardo Morras 2015-01-14 20:20:58 Re: PostgreSQL Dump rate is too slow
Previous Message Thomas Kellerer 2015-01-14 16:11:20 Re: How to identify all storage in a schema