Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TabZb-0006IM-Uk for pgsql-admin@postgresql.org; Tue, 20 Nov 2012 00:20:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TabZZ-0003Xd-5i for pgsql-admin@postgresql.org; Tue, 20 Nov 2012 00:20:19 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id qAK0KBDT016672; Mon, 19 Nov 2012 19:20:12 -0500 (EST) From: Tom Lane To: Samuel Stearns cc: "pgsql-admin@postgresql.org" Subject: Re: Resolving Index Bloat In-reply-to: References: Comments: In-reply-to Samuel Stearns message dated "Mon, 19 Nov 2012 21:59:59 +0000" Date: Mon, 19 Nov 2012 19:20:11 -0500 Message-ID: <16671.1353370811@sss.pgh.pa.us> X-Pg-Spam-Score: -2.3 (--) X-Archive-Number: 201211/105 X-Sequence-Number: 40350 Samuel Stearns writes: > We have a problem with index bloat on a couple of our tables even though we have applied more aggressive autovac/analyze settings in the schema: Hard to tell much about this without knowing the baseline condition or what's happened since the baseline. It looks like your tables have grown circa 2X (eg billingitemrating), but is that due to new data or heavy update activity? If the baseline condition is freshly-built-or-REINDEXed indexes, a fair amount of "bloat" is to be expected. The traditional rule of thumb about btree indexes is that the steady-state load factor is about two-thirds full. By default, PG builds indexes tightly packed --- so just allowing the index to reach steady state will incur 50% "bloat" on average. It's usually counterproductive to try to maintain a fill factor better than that, unless the table receives only minimal insert/update traffic. (Indeed, usually the better policy for a heavy-update table is to create the indexes with 66% fillfactor to begin with.) Your indexes on billingitemrating seem to have expanded a bit more than what would be expected from the combination of these factors, but I'm not sure they're enormously out of line. You could delve a bit deeper by using contrib/pgstattuple to measure the actual dead space in both the tables and the indexes. Also, it'd be useful to know the data types of the columns being indexed. regards, tom lane