Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6093DB62AC5 for ; Fri, 3 Jun 2011 13:02:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 50752-10 for ; Fri, 3 Jun 2011 16:02:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 2E63CB62AAD for ; Fri, 3 Jun 2011 13:02:03 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p53G229L028333; Fri, 3 Jun 2011 12:02:02 -0400 (EDT) To: Mark Stosberg cc: pgsql-admin@postgresql.org Subject: Re: surprised to find bloat in insert-only table In-reply-to: References: Comments: In-reply-to Mark Stosberg message dated "Fri, 03 Jun 2011 11:10:51 -0400" Date: Fri, 03 Jun 2011 12:02:02 -0400 Message-ID: <28332.1307116922@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/16 X-Sequence-Number: 37642 Mark Stosberg writes: > I recently set up partitioning on a table that sees heavy insert > traffic. There are never updates or deletes, we just drop the partitions > later. > It's my understanding that bloat can only appear through updates or > deletes, but these partitions are reported to have significant bloat in > them. Where else can this come from and how I can I reduce it? > I'm using a "bloat" view with 9.0.3 which might the same as this one: > https://wiki.postgresql.org/wiki/Show_database_bloat > This shows that each index on the table has over a gig of bloat: > select distinct(iname), wastedbytes, wastedsize from bloat where > wastedbytes > 0 order by wastedbytes DESC limit 20; > And this query also shows the same amount of bloat in the table itself: > select distinct(tablename), wastedbytes, wastedsize from bloat where > wastedbytes > 0 order by wastedbytes DESC limit 10; It's hard to evaluate that without knowing what the actual table/index sizes are, or IOW what is the reported bloat on a percentage basis? The view you mention isn't tremendously accurate --- AFAICS it isn't accounting for alignment padding between fields, page headers, and some other things. And it will consider the unused space on a page to be "bloat" even if it's too small to fit another tuple. So expecting the number to be zero is hopelessly optimistic. Also, indexes generally don't even try to pack pages completely full, so a larger percentage of unused space is to be expected for them. regards, tom lane