Re: Disk space usage discrepancy - Mailing list pgsql-general

From Tom Lane
Subject Re: Disk space usage discrepancy
Date
Msg-id 4603.1303588822@sss.pgh.pa.us
Whole thread Raw
In response to Disk space usage discrepancy  (Yang Zhang <yanghatespam@gmail.com>)
List pgsql-general
Yang Zhang <yanghatespam@gmail.com> writes:
> We're trying to figure out how to account for our disk space
> consumption in a database.

> $ sudo du -shx /var/lib/postgresql/8.4/main/
> 1.9G    /var/lib/postgresql/8.4/main/

> But when we query Postgresql to find out how much disk space is
> actually being used by the various databases, we get a total of under
> 600MB (the exact query we use for determining this is below, derived
> from the example query in the PG documentation):

>         select sum(pg_relation_size(oid)) from pg_class where relkind = 'r'

I think you need pg_total_relation_size() if you're doing it that way.
As is, you're missing out indexes and toast tables, and possibly also
secondary forks (I forget if 8.4 had those).

            regards, tom lane

pgsql-general by date:

Previous
From: "Henry C."
Date:
Subject: Re: 20110408pg_upgrade_fix and 'FATAL: could not access status of transaction...'
Next
From: Elliott Prechter
Date:
Subject: Re: setting local variable