Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 55407B5DBE4 for ; Tue, 19 Jul 2011 18:27:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 60500-05 for ; Tue, 19 Jul 2011 21:27:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 0B250B5DBE5 for ; Tue, 19 Jul 2011 18:27:41 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Tue, 19 Jul 2011 16:27:41 -0500 Message-Id: <4E25B07C020000250003F518@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Tue, 19 Jul 2011 16:27:40 -0500 From: "Kevin Grittner" To: "Ken Caruso" Cc: Subject: Re: Bloat and Slow Vacuum Time on Toast References: <4E25A7B7020000250003F502@gw.wicourts.gov> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.035 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.135 X-Spam-Level: X-Archive-Number: 201107/140 X-Sequence-Number: 37919 Ken Caruso wrote: > Kevin Grittner >> Ken Caruso wrote: >> >> >> > SELECT SUM(pg_relation_size(pg_class.oid)) >> > FROM pg_class ; >> >> Perhaps you want pg_total_relation_size()? > The number returned when using pg_total_relation size makes more > sense: 346GB. However it looked like pg_class has toast and > indexes listed individually, so I assumed that using > pg_total_relation_size would count values twice, because the total > relation size of table would include toast and indexes, and then > they would get counted again when I ran pg_total_relation_size on > the toast and indexes themselves. Is that an incorrect assumption > on my part? No that's a good point. On one of our production databases, externally: ccsa@SOCRATES:~> du -sh /var/pgsql/data/cc/ 2.2T /var/pgsql/data/cc/ internally: cir=# select pg_size_pretty(sum(pg_relation_size(pg_class.oid))::bigint) from pg_class; pg_size_pretty ---------------- 2176 GB (1 row) cir=# select pg_size_pretty(sum(pg_total_relation_size(pg_class.oid))::bigint) from pg_class; pg_size_pretty ---------------- 4223 GB (1 row) cir=# select pg_size_pretty(sum(pg_total_relation_size(pg_class.oid))::bigint) from pg_class where relkind = 'r'; pg_size_pretty ---------------- 2176 GB (1 row) You must have a lot of something outside of relations showing as active in pg_class taking up space. WAL files? Server logs? Temp files left over from crashes? -Kevin