Re: Working out diskspace taken by database and tables 7.4

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: frank church <pgsql(at)adontendev(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Working out diskspace taken by database and tables 7.4
Date: 2006-01-22 21:43:41
Message-ID: 20060122214341.GA69429@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jan 22, 2006 at 12:53:57PM +0000, frank church wrote:
> I am trying to work out how much space is taken up by a given
> database in the file system.

On Unix-like systems a simplistic way is to use "du" on the database
directory, which is generally $PGDATA/base/database_oid. You can
find the database oid by querying pg_database:

SELECT oid, datname FROM pg_database;

If you're using alternative locations (pre-8.0) or tablespaces (8.0
and later) then you'll need to take those directories into account.

See also "Monitoring Disk Usage" in the documentation:

http://www.postgresql.org/docs/7.4/interactive/diskusage.html
http://www.postgresql.org/docs/8.0/interactive/diskusage.html
http://www.postgresql.org/docs/8.1/interactive/diskusage.html

The contrib/dbsize functions mentioned in 8.0 and earlier have been
moved into the backend proper in 8.1.

http://www.postgresql.org/docs/8.1/interactive/functions-admin.html#FUNCTIONS-ADMIN-DBSIZE

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bob Pawley 2006-01-22 22:47:51 Re: Numbers
Previous Message Tom Lane 2006-01-22 19:25:33 Re: Numbers