pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Rubio <drubior@tinet.org>
To: pgsql-admin@postgresql.org
Subject: Re: schema sizes
Date: Thu, 03 Mar 2005 13:49:54 +0100
Message-ID: <422707F2.9090305@tinet.org> (raw)
In-Reply-To: <16934.48644.771352.662613@tanto-xipolis.de>
References: <4225B600.1000303@tinet.org>
	<16934.48644.771352.662613@tanto-xipolis.de>

Thanks, it works fine!!

Morus Walter wrote:

> 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.
> 
> 


-- 
********************************************************
Daniel Rubio Rodríguez
OASI (Organisme Autònom Per la Societat de la Informació)
c/ Assalt, 12
43003 - Tarragona
Tef.: 977.244.007 - Fax: 977.224.517
e-mail: drubio a oasi.org
********************************************************




view thread (3+ messages)

Message-ID: <422707F2.9090305@tinet.org>
Permalink:  ../422707F2.9090305@tinet.org/
Also on:    postgresql.org/message-id/422707F2.9090305@tinet.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: drubior@tinet.org
  Subject: Re: schema sizes
  In-Reply-To: <422707F2.9090305@tinet.org>
  References: <4225B600.1000303@tinet.org> <16934.48644.771352.662613@tanto-xipolis.de> <422707F2.9090305@tinet.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox