Re: How to tell how much of the database is being used for data.

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Steve Oualline <soualline(at)stbernard(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to tell how much of the database is being used for data.
Date: 2006-02-27 05:53:09
Message-ID: 20060227055309.GA39635@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Feb 24, 2006 at 03:04:27PM -0800, Steve Oualline wrote:
> Question: How can I tell how much free space is in the database itself?

contrib/pgstattuple shows dead tuple and free space statistics for
individual tables. Will that work?

> Background: We want to keep as many records as possible in the
> database as possible. Currently we fill the database until the disk
> usage reaches 80% then delete and VACUUM FULL the tables.

Are you deleting all records or only some? If all then TRUNCATE
would be faster than DELETE + VACUUM FULL and it would have the
same space-releasing effect, although it can't be used in all cases
(see the TRUNCATE documentation for more information).

> We'd like to just VACUUM but only VACUUM FULL is sure to
> release disk space to the operating system. However if we knew
> how much space was free in the database itself, we could judge how
> many new records we could dump into it.

If you intend to insert more data into the tables then what's the
purpose of giving space back to the OS when you're just going to
be allocating it again? With frequent vacuuming and reasonable FSM
settings you should be able to keep the tables around a certain
size. Or do you have usage patterns that make that infeasible?
If so, what are they?

What version of PostgreSQL are you running? How often do you do
regular vacuums?

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message S.Thanga Prakash 2006-02-27 07:13:07 Re: Operator for int8 array
Previous Message Bruno Wolff III 2006-02-27 03:20:30 Re: Wish: remove ancient constructs from Postgres