Re: Postgres Database size

From: Reece Hart <reece(at)harts(dot)net>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Cc: Mageshwaran <j_mageshwaran(at)sifycorp(dot)com>
Subject: Re: Postgres Database size
Date: 2007-03-18 01:14:17
Message-ID: 1174180457.4867.23.camel@snafu.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 2007-03-18 at 00:40 +0530, Mageshwaran wrote:
> how to find the size of a particular database in postgres...

The old way was to use du or similar. Recent versions (I believe >=8.1,
but check the release notes to be sure) provide several useful functions
for this:
pg_column_size
pg_database_size
pg_relation_size
pg_size_pretty
pg_tablespace_size
pg_total_relation_size

For example:

rkh(at)csb-dev=> select datname,pg_size_pretty(pg_database_size(oid)) from
pg_database ;
datname | pg_size_pretty
-----------------------------+----------------
postgres | 3905 kB
csb | 113 GB
template0 | 3840 kB
csb-dev | 124 GB
csb-dev-snapshot-2007-03-08 | 123 GB
csb_02_02_2007 | 121 GB
template1 | 3840 kB

--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0
./universe -G 6.672e-11 -e 1.602e-19 -protonmass 1.673e-27 -uspres bush
kernel warning: universe consuming too many resources. Killing.
universe killed due to catastrophic leadership. Try -uspres carter.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-03-18 01:21:45 Re: [PHP] works at command line but not in apache
Previous Message Bob Hartung 2007-03-18 00:59:03 Re: [PHP] works at command line but not in apache