Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 44103B5DC15 for ; Wed, 21 Sep 2011 10:03:20 -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 90427-06 for ; Wed, 21 Sep 2011 13:03:14 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from smtp.peak6.com (smtp.peak6.com [38.98.137.6]) by mail.postgresql.org (Postfix) with ESMTP id ED1E5B5DC1B for ; Wed, 21 Sep 2011 10:03:13 -0300 (ADT) X-AuditID: 0a64cb1e-b7b21ae000007ddb-77-4e79e08c0a78 Message-ID: <4E79E091.2030401@peak6.com> Date: Wed, 21 Sep 2011 08:03:13 -0500 From: Shaun Thomas Reply-To: Organization: Peak6 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: Venkat Balaji CC: PGSQL Performance Subject: Re: : Performance Improvement Strategy References: In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed content-transfer-encoding: 7bit X-Originating-IP: [10.10.220.61] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrEIsWRmVeSWpSXmKPExsXCxcQrptv7oNLP4M01RovrM88xWyx6vJbF gcnjwr5p7B6THkxhC2CKamC0SczLyy9JLElVSEktTrZVCnB19DZTCC5JzEtJLEpRcMksTs5J zMxNLVJSyEyxVTJSUijISUxOzU3NK7FVSiwoSM1LUbLjUsAANkBlmXkKqXnJ+SmZeem2Sp7B /roWFqaWuoZKdvEIkNDNkrGpcwd7QQN/xfTVaQ2M/7m7GDk5JARMJN6cWcUIYYtJXLi3nq2L kYODV0BDYs+kUpAwi4CqxOzW96wgNpuAmsTC3TfByoUEZCX2rzoHFucXEJbY96GJGcQWFQiQ WDDpLVgNr4CgxMmZT1hAbBEBLYkjRy+DxZkFLCT+XvoIZgsLWEp8ffSDHWJmgMScLffA5nAK BEocO7oMqt5W4sKc6ywQtrzE9rdzmCHq5STuNDwHO1lCQEHi+nL/CYxCs5BsnoWkexaS7gWM zKsYxYvLEpMzMk0LinNLCgz1ClITs8308lJLNjGCYjbltNwOxulLFQ8xCnAwKvHwTjpW4SfE mlhWXJl7iFGCg1lJhLf/TqWfEG9KYmVValF+fFFpTmrxIUZtYJBNZJbiTs4HppO8knhjAwMl cd6YP5l+QgLpwBSQnZpakFoEU83EwSnVwHhiAwff05KKS/MUt9llfur8Wiq3tiix6uZqblvO fnMzfl3pwBm+Vx/khFzL3pr/sTbqkZFsTcen8yuCpDTt/i2bccfiCbuWqw//WqvDe6YcZo78 cjIp4UHLt6R5snK6LqHcf5fuLCuK2MMcW2bv8SHowvacXc61K16+ZLz8sKRGlcdK+2HGByWW 4oxEQy3mouJEAHb/x8zlAgAA 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/315 X-Sequence-Number: 45091 On 09/20/2011 11:22 AM, Venkat Balaji wrote: > Please help me understand how to calculate free space in Tables and > Indexes even after vacuuming and analyzing is performed. Besides the query Mark gave you using freespacemap, there's also the pgstattuple contrib module. You'd use it like this: SELECT pg_size_pretty(free_space) AS mb_free FROM pgstattuple('some_table'); Query must be run as a super-user, and I wouldn't recommend running it on huge tables, since it scans the actual data files to get its information. There's a lot of other useful information in that function, such as the number of dead rows. > What i understand is that, even if we perform VACUUM ANALYZE > regularly, the free space generated is not filled up. VACUUM does not actually generate free space. It locates and marks reusable tuples. Any future updates or inserts on that table will be put in those newly reclaimed spots, instead of being bolted onto the end of the table. > 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. Why? If your database is so desperate for space, VACUUM and REINDEX won't really help you. A properly maintained database will still have a certain amount of "bloat" equal to the number of rows that change between maintenance intervals. One way or another, that space is going to be used by *something*. It sounds more like you need to tweak your autovacuum settings to be more aggressive if you're seeing significant enough turnover that your tables are bloating significantly. One of our tables, for instance, gets vacuumed more than once per hour because it experiences 1,000% turnover daily. -- Shaun Thomas OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604 312-676-8870 sthomas@peak6.com ______________________________________________ See http://www.peak6.com/email-disclaimer/ for terms and conditions related to this email