Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T13VA-00029v-Jr for pgsql-performance@postgresql.org; Mon, 13 Aug 2012 22:52:48 +0000 Received: from [2404:130:0:10::40:2] (helo=mail.catalyst.net.nz) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T13V5-0002f8-8H for pgsql-performance@postgresql.org; Mon, 13 Aug 2012 22:52:45 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id 9DB5232DEB; Tue, 14 Aug 2012 10:52:36 +1200 (NZST) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8PN+QP6c2Ba2; Tue, 14 Aug 2012 10:52:35 +1200 (NZST) Received: from [IPv6:2404:130:0:1000:9137:d8eb:f738:4fb1] (unknown [IPv6:2404:130:0:1000:9137:d8eb:f738:4fb1]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id C99FA31E02; Tue, 14 Aug 2012 10:52:35 +1200 (NZST) Message-ID: <50298533.7050904@catalyst.net.nz> Date: Tue, 14 Aug 2012 10:52:35 +1200 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: =?UTF-8?B?U3RyYWhpbmphIEt1c3R1ZGnEhw==?= CC: pgsql-performance@postgresql.org Subject: Re: Index Bloat Problem References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2404:130:0:10::40:2 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201208/74 X-Sequence-Number: 47612 On 11/08/12 10:15, Strahinja Kustudi=C4=87 wrote: > We have PostgreSQL 9.1 running on Centos 5 on two SSDs, one for indices= and > one for data. The database is extremely active with reads and writes. W= e > have autovacuum enabled, but we didn't tweak it's aggressiveness. The > problem is that after some time the database grows even more than 100% = on > the file system and most of the growth is because the indices are a few > times bigger than they should be, and when this happens, the performanc= e of > the DB drops. > > For example, yesterday when I checked the database size on the producti= on > server it was 30GB, and the restored dump of that database was only 17G= B. > The most interesting thing is that the data wasn't bloated that much, b= ut > the indices were. Some of them were a few times bigger than they should= be. > For example an index on the production db is 440MB, while that same ind= ex > after dump/restore is 17MB, and there are many indices with that high > difference. We could fix the problem if we reindex the DB, but that mak= es > our DB go offline and it's not possible to do in the production envirom= ent. > > Is there a way to make the autovacuum daemon more aggressive, since I'm= not > exactly sure how to do that in this case? Would that even help? Is ther= e > another way to remove this index bloat? > > Some workloads can be difficult to tame. However I would try something=20 like this in postgresql.conf: autovacuum_naptime=3D 10s autovacuum_vacuum_scale_factor =3D 0.1 and maybe set log_autovacuum_min_duration so you see what autovacuum is=20 doing. If the above settings don't help, then you could maybe monitor growth=20 and schedule regular REINDEXes on the tables concerned (at some suitably=20 quiet time). Regards Mark