Re: Does it has a way to compact the database size?

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Premsun Choltanwanich" <Premsun(at)nsasia(dot)co(dot)th>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Does it has a way to compact the database size?
Date: 2007-03-06 13:58:11
Message-ID: b42b73150703060558g73874d5o1c8a6817b69e9aef@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/6/07, Premsun Choltanwanich <Premsun(at)nsasia(dot)co(dot)th> wrote:
> I use PostgreSQL 8.0.3 for store my data started on Sep'06. Today, I use database_size('name') function for checking my database size and found that it's about 1209715345.
>
> I think that something maybe wrong on my database because I backup my database everyday and the backup size is about 10 MB. So I restore databse from my backup file then use database_size('name') function again and found that database size is about 56642193.
>
> I can said both 1209715345 and 56642193 are coming from the same database but I wonder that why it quiet difference on size.
>
> Any Idea?
> And How can I control or compact my database size for make it smallest as possibled?

It's not a bug it's a feature...regular (non full) vacuum reclaims
free space for the database to use but does not release it back to the
operating system. PostgreSQL will allocate space for extra storage
out of that 'free' space first before it asks for more from the
operating system. I wouldn't worry about it too much unless you were
concerned about running out of space. As long as you vacuum regularly
(or use autovacuum), growth will moderate to the actual growth of your
database.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message .ep 2007-03-06 14:24:26 Importing *huge* mysql database into pgsql
Previous Message Kenneth Downs 2007-03-06 13:48:05 Re: M:M table conditional delete for parents