Re: How can I known the size of a database, table by table ?

From: "Shoaib Mir" <shoaibmir(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I known the size of a database, table by table ?
Date: 2006-03-27 17:38:41
Message-ID: bf54be870603270938w28798f9blc61b5c98e58074a5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The space occupied by your database and tables can be found this way:

# select oid from pg_database where datname='mybase';

oid
-------
17239
(1 row)

$ du -hs data/base/17239
13.5 M

For getting a table size to get an approx size you can do the following:

SELECT relpages * 8192 AS size_in_bytes
FROM pg_class
WHERE

relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = '<schema
name>') AND

relname = '<table name>';

/Shoaib

On 3/27/06, Bruno Baguette < pgsql-ml(at)baguette(dot)net> wrote:
>
> Hello,
>
> I works on a PostgreSQL 8.0.4 database, and I would like to known the
> size (in bytes, Mbytes or anything else) of that database, for each table.
>
> How can I do that ?
>
> Thanks in advance !
>
> --
> Bruno BAGUETTE
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2006-03-27 17:44:12 Re: Advantages of PostgreSQL over MySQL 5.0
Previous Message Andreas Kretschmer 2006-03-27 17:33:29 Re: How can I known the size of a database, table by table ?