Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 97DC663296A for ; Tue, 6 Jul 2010 16:50:38 -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 53514-09 for ; Tue, 6 Jul 2010 19:50:29 +0000 (UTC) X-Greylist: delayed 00:07:37.20714 by SQLgrey-1.7.6 Received: from na3sys009aog110.obsmtp.com (na3sys009aog110.obsmtp.com [74.125.149.203]) by mail.postgresql.org (Postfix) with ESMTP id 1AEDA632265 for ; Tue, 6 Jul 2010 16:50:29 -0300 (ADT) Received: from source ([209.85.161.52]) by na3sys009aob110.postini.com ([74.125.148.12]) with SMTP ID DSNKTDOJBFNfolLcn7Ur3a1NdkJivatxaYS1@postini.com; Tue, 06 Jul 2010 12:50:29 PDT Received: by mail-fx0-f52.google.com with SMTP id 8so5370906fxm.25 for ; Tue, 06 Jul 2010 12:50:28 -0700 (PDT) Received: by 10.223.122.82 with SMTP id k18mr4877969far.32.1278445368994; Tue, 06 Jul 2010 12:42:48 -0700 (PDT) Received: from [10.1.128.1] (rrcs-70-60-73-130.central.biz.rr.com [70.60.73.130]) by mx.google.com with ESMTPS id q8sm12647561faa.34.2010.07.06.12.42.46 (version=SSLv3 cipher=RC4-MD5); Tue, 06 Jul 2010 12:42:48 -0700 (PDT) Message-ID: <4C338735.2080809@securityconfidence.com> Date: Tue, 06 Jul 2010 15:42:45 -0400 From: Brian Helm User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: How To Calculate Table Size Minus Deleted Rows X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.5 tagged_above=-5 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201007/20 X-Sequence-Number: 34333 I'm in the need of a way to determine the disk size of a table that excludes dead tuples. Here is my situation. Our company would like to provide a "rolling storage" solution on a per schema basis. So basically we set a "quota" of the amount of disk space that a schema can occupy. Every night a cron job is run that calculates the overage of each schema's quota and deletes as many rows as necessary from each table to bring the schema back within quota limits. I was trying to use pg_total_relation_size to calculate the amount of space consumed by each table, but I quickly learned that even after deleting/vacuuming, the reported size of the table does not drop. I assume this is due to the nature of how a lazy vacuum works. Is there a way to get the size of the table that excludes the freed (but not released) space from a delete/vacuum run? -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Brian Helm Security Confidence Corporation Brian.Helm@SecurityConfidence.com 513.388-4500/866.732.2661 Ext 106 www.SecurityConfidence.com