Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C0A971337B81 for ; Wed, 4 May 2011 13:49: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 15391-05 for ; Wed, 4 May 2011 16:49:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 81E141337B61 for ; Wed, 4 May 2011 13:49:02 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QHfG1-0007ml-6v for pgsql-admin@postgresql.org; Wed, 04 May 2011 18:49:01 +0200 Received: from frigga.summersault.com ([12.161.105.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 May 2011 18:49:01 +0200 Received: from mark by frigga.summersault.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 May 2011 18:49:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-admin@postgresql.org From: Mark Stosberg Subject: Re: best practice for moving millions of rows to child table when setting up partitioning? Date: Wed, 04 May 2011 12:48:44 -0400 Lines: 22 Message-ID: References: <659395.83416.qm@web39708.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: frigga.summersault.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: <659395.83416.qm@web39708.mail.mud.yahoo.com> X-Enigmail-Version: 1.1.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.595 tagged_above=-10 required=5 tests=BAYES_00=-1.9, SARE_MILLIONSOF=0.315, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/41 X-Sequence-Number: 37478 >> 5. Finally, I'll drop the indexes on the parent table and >> truncate it. Luckily I noticed the problem with TRUNCATE and partitioning before my work got to production. TRUNCATE cascades automatically and silently to child tables, which was not my intent. This is mentioned here: http://wiki.postgresql.org/wiki/Table_partitioning But is not mentioned in the official documentation for TRUNCATE: http://www.postgresql.org/docs/9.0/static/sql-truncate.html The work-around we used was to put the TRUNCATE statement ahead of the ALTER TABLE .. INHERIT statements in our final transaction. Mark