Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 106896329CC for ; Sat, 27 Mar 2010 10:35:58 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 33166-06 for ; Sat, 27 Mar 2010 13:35:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from marajade.localdomain (vcs5.camavision.com [63.228.164.252]) by mail.postgresql.org (Postfix) with ESMTP id 56839632F32 for ; Sat, 27 Mar 2010 10:35:47 -0300 (ADT) Received: from [192.168.1.103] (173-20-246-8.client.mchsi.com [173.20.246.8]) (Authenticated sender: andy) by marajade.localdomain (Postfix) with ESMTPA id 778D550BD8; Sat, 27 Mar 2010 08:35:44 -0500 (CDT) Message-ID: <4BAE09AE.9020305@squeakycode.net> Date: Sat, 27 Mar 2010 08:35:42 -0500 From: Andy Colson User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Lightning/1.0b1 Thunderbird/3.0.3 MIME-Version: 1.0 To: Gnanakumar , pgsql-performance@postgresql.org Subject: Re: Database size growing over time and leads to performance impact References: <004701cacdad$7013e9f0$503bbdd0$@com> In-Reply-To: <004701cacdad$7013e9f0$503bbdd0$@com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.392 tagged_above=-10 required=5 tests=AWL=1.207, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/345 X-Sequence-Number: 38170 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/ > > 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. Vacuum is not meant to reduce size of the db, its meant to mark pages for reuse. VACUUM FULL is almost never needed. The fact it didnt reduce your db size is probably because of something else, like an open transaction. If you have a transaction left open, then your db will never be able to shrink or re-use pages. You'd better fix that issue first. (run ps -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 autovacuum do 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