Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 067B1632BAE for ; Sun, 20 Jun 2010 11:22:24 -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 22138-07 for ; Sun, 20 Jun 2010 14:22:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f46.google.com (mail-bw0-f46.google.com [209.85.214.46]) by mail.postgresql.org (Postfix) with ESMTP id 998F66327EE for ; Sun, 20 Jun 2010 11:22:16 -0300 (ADT) Received: by bwz7 with SMTP id 7so600431bwz.19 for ; Sun, 20 Jun 2010 07:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:received :in-reply-to:references:date:message-id:subject:from:to:cc :content-type; bh=inxpsAslFKE6KQN0pxTUWxUiK/qwoB4du5tQI+trj9s=; b=RJQ3eTeL0uAik4orRoZXuRgtNHAd2wr/vpMSk3fr+J2by2jtbuWJ0eGsk4hZrNycWU M9xEvuvluP39mLN/ZK/bFhE+8mVzh8KchpzcxZjfspR/SBf4cs4+kLzfC1rUU5Wp6TEO /luUmDhcGqynRIctAw6E9/JcCYLgrdXyJqZWs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=WMGhGx78/CfTWh30hTN6iDTJcm0VuI/y2902167Ns+fn+SYh6JLxtZSXL56ebAbufV ZMpsHY/GXUsKYxNDYV7oFJsIBmweoJlFLp+O3tgYZ2m4i28UfkmmJBAS4Aosou3qUnJ4 wDkwyyYEv8/TVgn+Xo1kWHzng4VtyzW7eLXUE= MIME-Version: 1.0 Received: by 10.204.83.30 with SMTP id d30mr1865562bkl.125.1277043733935; Sun, 20 Jun 2010 07:22:13 -0700 (PDT) Received: by 10.204.59.66 with HTTP; Sun, 20 Jun 2010 07:22:13 -0700 (PDT) Received: by 10.204.59.66 with HTTP; Sun, 20 Jun 2010 07:22:13 -0700 (PDT) In-Reply-To: References: Date: Sun, 20 Jun 2010 09:22:13 -0500 Message-ID: Subject: Re: Obtaining the exact size of the database. From: Dave Crooke To: venu madhav Cc: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=0016e6ddab561fb4e4048976ea27 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-10 required=5 tests=BAYES_20=-0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201006/353 X-Sequence-Number: 39209 --0016e6ddab561fb4e4048976ea27 Content-Type: text/plain; charset=UTF-8 Hi there 1. PG 8.1.9 is ancient ... you should upgrade. 2. The database gross size on disk is not affected by VACUUM ANALYZE ... all this does is return space used by deleted row-versions to PG for re-use. The only way to reduce it and thus return disk space to the OS is to do a VACUUM FULL, or to delete the entire table. 3. If you can suspend writes for a while, you can pull off an "online" VACCUM FULL, or copy and delete the table in order to repack it. Check out the CLUSTER command. 4. If you're trying to figure out the net size of the table, i.e. how much free space is inside the table files for reuse by PG, then you need the pg_stat_tuple function ... this is built in to PG 8.4, and a plug-in activated by a script for PG 8.3, don't know if it exists in 8.1 or not. Like SELECT COUNT(*) this requires a full table scan. Cheers Dave sent from my Android phone On Jun 20, 2010 6:18 AM, "venu madhav" wrote: Hi All, I am using Postgres 8.1.9 for my application. My application also has a clean up module which cleans up specified percentage of total database size at regular intervals. Now the problem is I use *pg_database_size* to obtain the size of the database. After deleting the records, we run *Vacuum Analyze* to reorder the indexes. The problem here is even though some records are cleared, it still shows the original DB Size. Is there any way to find out the actual DB Size or it would be more useful, if I can get the size of each table. I can't run *Vacuum Full* because the application should be run 24*7 without downtime. Can someone please help me in solving this. Please let me know if you need any clarifications. Thank you, Venu. --0016e6ddab561fb4e4048976ea27 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Hi there

1. PG 8.1.9 is ancient ... you should upgrade.

2. The database gross size on disk is not affected by VACUUM ANALYZE ...= all this does is return space used by deleted row-versions to PG for re-us= e. The only way to reduce it and thus return disk space to the OS is to do = a VACUUM FULL, or to delete the entire table.

3. If you can suspend writes for a while, you can pull off an "onli= ne" VACCUM FULL, or copy and delete the table in order to repack it. C= heck out the CLUSTER command.

4. If you're trying to figure out the net size of the table, i.e. ho= w much free space is inside the table files for reuse by PG, then you need = the pg_stat_tuple function ... this is built in to PG 8.4, and a plug-in ac= tivated by a script for PG 8.3, don't know if it exists in 8.1 or not. = Like SELECT COUNT(*) this requires a full table scan.

Cheers
Dave

sent from my Android phone

On Jun 20, 2010 6:18 AM, "venu madhav&quo= t; <venutaurus539@gmail.com> wrote:

Hi All,
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 I am using P= ostgres 8.1.9 for my application. My application also has a clean up module= which cleans up specified percentage of total database size at regular int= ervals. Now the problem is I use pg_database_size to obtain the size= of the database. After deleting the records, we run Vacuum Analyze = to reorder the indexes. The problem here is even though some records are cl= eared, it still shows the original DB Size. Is there any way to find out th= e actual DB Size or it would be more useful, if I can get the size of each = table.
=C2=A0=C2=A0=C2=A0=C2=A0 I can't run Vacuum Full because the app= lication should be run 24*7 without downtime.

Can someone please hel= p me in solving this.

Please let me know if you need any clarificati= ons.

Thank you,
Venu.

--0016e6ddab561fb4e4048976ea27--