From: Alvaro Herrera <alvherre@surnet.cl>
To: Steve Lane <slane@soliantconsulting.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Convenient dump of table and object size in PG 7.4
Date: Thu, 26 May 2005 22:48:12 -0400
Message-ID: <20050527024812.GB18417@surnet.cl> (raw)
In-Reply-To: <BEBBF290.19D5F%slane@soliantconsulting.com>
References: <4294CFC0.6040901@ca.afilias.info>
<BEBBF290.19D5F%slane@soliantconsulting.com>
On Thu, May 26, 2005 at 09:39:26PM -0500, Steve Lane wrote:
> Attached is a view I wrote for postgres 7.4 that seems to provide pretty
> accurate reporting of table sizes. For each non-system table in a database
> it shows base table size, size of any related TOAST data, and aggregate size
> of indexes.
>
> The code is somewhat ugly in that it contains a bunch of CASE statements the
> sole point of which is to transform the occasional NULL into a 0.
>
> Object sizes are computed from pg_class.relpages with an assumed page size
> of 8192.
>
> Comments and improvements most welcome.
You could change all those "CASE WHEN foo IS NULL THEN 0 ELSE foo" into
COALESCE(foo, 0).
Additionally, "show block_size" will give you the block (page) size. I
don't see how would you use that in a query though.
--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"La tristeza es un muro entre dos jardines" (Khalil Gibran)
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: alvherre@surnet.cl, slane@soliantconsulting.com
Subject: Re: Convenient dump of table and object size in PG 7.4
In-Reply-To: <20050527024812.GB18417@surnet.cl>
References: <4294CFC0.6040901@ca.afilias.info> <BEBBF290.19D5F%slane@soliantconsulting.com> <20050527024812.GB18417@surnet.cl>
* 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