Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 789DBB5DC0C for ; Tue, 20 Sep 2011 19:05:17 -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 25625-07 for ; Tue, 20 Sep 2011 22:05:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail.catalyst.net.nz (bertrand.catalyst.net.nz [202.78.240.40]) by mail.postgresql.org (Postfix) with ESMTP id 20204B5DC01 for ; Tue, 20 Sep 2011 19:05:10 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id 30B7C325F0; Wed, 21 Sep 2011 10:05:08 +1200 (NZST) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HjBLVMNO-tBv; Wed, 21 Sep 2011 10:05:07 +1200 (NZST) Received: from [IPv6:2404:130:0:1000:222:15ff:fe5c:2471] (unknown [IPv6:2404:130:0:1000:222:15ff:fe5c:2471]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id 9438A3258E; Wed, 21 Sep 2011 10:05:07 +1200 (NZST) Message-ID: <4E790E13.8060308@catalyst.net.nz> Date: Wed, 21 Sep 2011 10:05:07 +1200 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 Thunderbird/3.1.13 MIME-Version: 1.0 To: Josh Berkus CC: pgsql-performance@postgresql.org Subject: Re: : Performance Improvement Strategy References: <4E78D6EC.30205@agliodbs.com> In-Reply-To: <4E78D6EC.30205@agliodbs.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/292 X-Sequence-Number: 45068 On 21/09/11 06:09, Josh Berkus wrote: > Venkat, > >> I see lot of free spaces or free pages in Tables and Indexes. But, I need to >> give an exact calculation on how much space will be reclaimed after VACUUM >> FULL and RE-INDEXING. > At present, there is no way to calculate this precisely. You can only > estimate, and estimates have significant error factors. The query which > Marcin linked for you, for example, can be as much as 500% off (although > usually only 50% off). > If you have autovacuum on (which should be typical thee days), then using the freespacemap contrib module should give very accurate results: SELECT oid::regclass, pg_relation_size(oid)/(1024*1024) AS mb, sum(free)/(1024*1024) AS free_mb FROM (SELECT oid, (pg_freespace(oid)).avail AS free FROM pg_class) AS a GROUP BY a.oid ORDER BY free_mb DESC; regards Mark