Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E464E1337BE4 for ; Wed, 4 May 2011 21:10: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 33979-04 for ; Thu, 5 May 2011 00:10:10 +0000 (UTC) X-Greylist: delayed 00:05:17.01159 by SQLgrey-1.7.6 Received: from mh1.mail.rice.edu (mh1.mail.rice.edu [128.42.201.20]) by mail.postgresql.org (Postfix) with ESMTP id DFF5F1337B47 for ; Wed, 4 May 2011 21:10:09 -0300 (ADT) Received: from mh1.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh1.mail.rice.edu (Postfix) with ESMTP id 9E9F52907A8; Wed, 4 May 2011 19:04:51 -0500 (CDT) X-Virus-Scanned: by amavis-2.6.4 at mh1.mail.rice.edu, auth channel Received: from mh1.mail.rice.edu ([127.0.0.1]) by mh1.mail.rice.edu (mh1.mail.rice.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id Tqb5Ky1Fdjlb; Wed, 4 May 2011 19:04:51 -0500 (CDT) Received: from localhost (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: ktm) by mh1.mail.rice.edu (Postfix) with ESMTPSA id 72C4C290796; Wed, 4 May 2011 19:04:51 -0500 (CDT) Received: from c-76-30-200-52.hsd1.tx.comcast.net (c-76-30-200-52.hsd1.tx.comcast.net [76.30.200.52]) by webmail.rice.edu (Horde Framework) with HTTP; Wed, 04 May 2011 19:04:51 -0500 Message-ID: <20110504190451.1123213u1k1v878j@webmail.rice.edu> Date: Wed, 04 May 2011 19:04:51 -0500 From: ktm@rice.edu To: Mark Stosberg Cc: pgsql-admin@postgresql.org Subject: Re: Re: best practice for moving millions of rows to child table when setting up partitioning? References: <659395.83416.qm@web39708.mail.mud.yahoo.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.3.7) X-Horde-Authenticated: ktm X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.195 tagged_above=-10 required=5 tests=BAYES_05=-0.5, SARE_MILLIONSOF=0.315, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/56 X-Sequence-Number: 37493 Quoting Mark Stosberg : > >>> 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 You need to use the "ONLY" option to TRUNCATE to just do the single parent and not cascade to the child tables. Regards, Ken