Re: schema sizes

Поиск
Список
Период
Сортировка
От Morus Walter
Тема Re: schema sizes
Дата
Msg-id 16934.48644.771352.662613@tanto-xipolis.de
обсуждение исходный текст
Ответ на schema sizes  (Daniel Rubio <drubior@tinet.org>)
Ответы Re: schema sizes  (Daniel Rubio <drubior@tinet.org>)
Список pgsql-admin
Daniel Rubio writes:
> Hi all!
>
> We want to obtain the size of the diferent schemas of some databases.
> We've installed dbsize and it works fine, but it returns the size of all
> the database.
> Exists some method to determine the size of a concrete schema?
>
I use
SELECT nspname,
sum(relpages * cast( 8192 AS bigint )) as "table size",
sum( ( select sum(relpages)      from pg_class i, pg_index idx      where i.oid = idx.indexrelid      and
t.oid=idx.indrelid) ) * cast( 8192 AS bigint ) as "index size",  
sum ( relpages * cast( 8192 AS bigint ) + ( select sum(relpages)      from pg_class i, pg_index idx      where i.oid =
idx.indexrelid     and t.oid=idx.indrelid ) * cast( 8192 AS bigint ) ) as "size"   
FROM pg_class t, pg_namespace
WHERE relnamespace = pg_namespace.oid
and pg_namespace.nspname not like 'pg_%'
and pg_namespace.nspname != 'information_schema'
and relkind = 'r' group by nspname;

to sum over all tables/indices of a schema.
Note that the input for the sum is relpages in pg_class and this value
is only updated by VACUUM, ANALYZE und CREATE INDEX.
So you should analyze all tables before you execute the statement.

В списке pgsql-admin по дате отправления:

Предыдущее
От: Marco Rademeyer
Дата:
Сообщение: Re: Application gui
Следующее
От: juanmime@ono.com
Дата:
Сообщение: How to deny remote backups ?