Re: Database size growing over time and leads to performance impact - Mailing list pgsql-performance

From Andy Colson
Subject Re: Database size growing over time and leads to performance impact
Date
Msg-id 4BAE09AE.9020305@squeakycode.net
Whole thread Raw
In response to Database size growing over time and leads to performance impact  ("Gnanakumar" <gnanam@zoniac.com>)
Responses Re: Database size growing over time and leads to performance impact  ("Gnanakumar" <gnanam@zoniac.com>)
Re: Database size growing over time and leads to performance impact  (Scott Carey <scott@richrelevance.com>)
List pgsql-performance
On 03/27/2010 08:00 AM, Gnanakumar wrote:
> Hi,
>
> We're using PostgreSQL 8.2. Recently, in our production database, there
> was a severe performance impact.. Even though, we're regularly doing both:
>
> 1. VACUUM FULL ANALYZE once in a week during low-usage time and
>
> 2. ANALYZE everyday at low-usage time
>
> Also, we noticed that the physical database size has grown upto 30 GB.
> But, if I dump the database in the form of SQL and import it locally in
> my machine, it was only 3.2 GB. Then while searching in Google to
> optimize database size, I found the following useful link:
>
> http://www.linuxinsight.com/optimize_postgresql_database_size.html
>
> It says that even vacuumdb or reindexdb doesn't really compact database
> size, only dump/restore does because of MVCC architecture feature in
> PostgreSQL and this has been proven here.
>
> So, finally we decided to took our production database offline and
> performed dump/restore. After this, the physical database size has also
> reduced from 30 GB to 3.5 GB and the performance was also very good than
> it was before.
>
> Physical database size was found using the following command:
>
> du -sh /usr/local/pgsql/data/base/<database-oid>
>
> I also cross-checked this size using
> "pg_size_pretty(pg_database_size(datname))".
>
> Questions
>
> 1. Is there any version/update of PostgreSQL addressing this issue?
>
> 2. How in real time, this issues are handled by other PostgreSQL users
> without taking to downtime?
>
> 3. Any ideas or links whether this is addressed in upcoming PostgreSQL
> version 9.0 release?
>

The "issue" is not with PG's.  Any newer version of PG will act exactly the same.  I don't think you understand.
Vacuumis not meant to reduce size of the db, its meant to mark pages for reuse.  VACUUM FULL is almost never needed.
Thefact it didnt reduce your db size is probably because of something else, like an open transaction.  If you have a
transactionleft open, then your db will never be able to shrink or re-use pages.  You'd better fix that issue first.
(runps -ax|grep postgres  and look for "idle in transaction") 

You need to vacuum way more often than once a week.  Just VACUUM ANALYZE, two, three times a day.  Or better yet, let
autovacuumdo its thing.  (if you do have autovacuum enabled, then the only problem is the open transaction thing). 

Dont "VACUUM FULL", its not helping you, and is being removed in newer versions.

-Andy

pgsql-performance by date:

Previous
From: "Gnanakumar"
Date:
Subject: Database size growing over time and leads to performance impact
Next
From: "Pierre C"
Date:
Subject: Re: Database size growing over time and leads to performance impact