Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 59DD91337B67 for ; Tue, 29 Mar 2011 13:27:13 -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 98039-05 for ; Tue, 29 Mar 2011 16:27:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og103.obsmtp.com (exprod7og103.obsmtp.com [64.18.2.159]) by mail.postgresql.org (Postfix) with ESMTP id 8086E1337B47 for ; Tue, 29 Mar 2011 13:27:05 -0300 (ADT) Received: from source ([209.85.216.48]) (using TLSv1) by exprod7ob103.postini.com ([64.18.6.12]) with SMTP ID DSNKTZIIWJSdDBrMGhdaGdvOyU5MNeg7nAJm@postini.com; Tue, 29 Mar 2011 09:27:05 PDT Received: by mail-qw0-f48.google.com with SMTP id 9so267219qwj.7 for ; Tue, 29 Mar 2011 09:27:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.53.79 with SMTP id l15mr4665219qcg.83.1301416022911; Tue, 29 Mar 2011 09:27:02 -0700 (PDT) Received: by 10.229.227.141 with HTTP; Tue, 29 Mar 2011 09:27:02 -0700 (PDT) In-Reply-To: <1301414165.2351.1435136873@webmail.messagingengine.com> References: <1301414165.2351.1435136873@webmail.messagingengine.com> Date: Tue, 29 Mar 2011 21:57:02 +0530 Message-ID: Subject: Re: full vacuum of a very large table From: Ashish Nauriyal To: Nic Chidu Cc: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=0015175ca84ec02d6a049fa18718 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201103/260 X-Sequence-Number: 37132 --0015175ca84ec02d6a049fa18718 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Mar 29, 2011 at 9:26 PM, Nic Chidu wrote: > Got a situation where a 130 mil rows (137GB) table needs to be brought down > in size to 10 mil records (most recent) > with the least amount of downtime. > > What version of PG are you with ? If PG>8.2 and have disk space twice the size of target table and indexes, you can reorganize the table using pg_reorg without locking table with concurrent selections and updations. http://reorg.projects.postgresql.org/pg_reorg.html > Doing a full vacuum would be faster on: > - 120 mil rows deleted and 10 mil active (delete most of them then full > vacuum) > - 10 mil deleted and 120 mil active. (delete small batches and full vacuum > after each delete). > > Any other suggestions? > > Thanks, > > Nic > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin > -- Thanks, Ashish Nauriyal EnterpriseDB Corporation The Enterprise Postgres Company --0015175ca84ec02d6a049fa18718 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Tue, Mar 29, 2011 at 9:26 PM, Nic Chi= du <nic@chidu.net= > wrote:
Got a situation where a 130 mil rows (137GB) table needs to be brought down= in size to =A010 mil records (most recent)
with the least amount of downtime.


What version of PG are you with ?
If PG>8.2 =A0and have disk space twice the size of target table an= d indexes, you can reorganize the table using pg_reorg without locking tabl= e with concurrent selections and updations.

= =A0
Doing a full vacuum would be faster on:
=A0- 120 mil rows deleted and 10 mil active (delete most of them then full = vacuum)
=A0- 10 mil deleted and 120 mil active. (delete small batches and full vacu= um after each delete).

Any other suggestions?

Thanks,

Nic

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



--
Thanks,
Ashis= h Nauriyal
EnterpriseDB Corporation
The Enterprise Postgres Company

--0015175ca84ec02d6a049fa18718--