Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZB9dJ-0000Tx-SW for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2015 22:40:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZB9dI-0005nc-TZ for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2015 22:40:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZB9bZ-00049k-CP for pgsql-hackers@postgresql.org; Fri, 03 Jul 2015 22:38:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZB9bW-00051z-3h for pgsql-hackers@postgresql.org; Fri, 03 Jul 2015 22:38:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t63McbdB021534; Fri, 3 Jul 2015 18:38:37 -0400 From: Tom Lane To: Andres Freund cc: Fujii Masao , Martijn van Oosterhout , PostgreSQL-development Subject: Re: WAL logging problem in 9.4.3? In-reply-to: <20150703223216.GO3291@awork2.anarazel.de> References: <20150702222102.GG30708@awork2.anarazel.de> <20150703052048.GA20285@svana.org> <20150703060137.GB20285@svana.org> <28320.1435935120@sss.pgh.pa.us> <20150703164931.GI3291@awork2.anarazel.de> <20150703170229.GJ3291@awork2.anarazel.de> <20150703172605.GM3291@awork2.anarazel.de> <20150703223216.GO3291@awork2.anarazel.de> Comments: In-reply-to Andres Freund message dated "Sat, 04 Jul 2015 00:32:16 +0200" Date: Fri, 03 Jul 2015 18:38:37 -0400 Message-ID: <21533.1435963117@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Andres Freund writes: > On 2015-07-03 19:26:05 +0200, Andres Freund wrote: >> commit cab9a0656c36739f59277b34fea8ab9438395869 >> Author: Tom Lane >> Date: Sun Aug 23 19:23:41 2009 +0000 >> >> Make TRUNCATE do truncate-in-place when processing a relation that was created >> or previously truncated in the current (sub)transaction. This is safe since >> if the (sub)transaction later rolls back, we'd just discard the rel's current >> physical file anyway. This avoids unreasonable growth in the number of >> transient files when a relation is repeatedly truncated. Per a performance >> gripe a couple weeks ago from Todd Cook. >> >> to me the reasoning here looks flawed. > It looks to me we need to re-neg on this a bit. I think we can still be > more efficient than the general codepath: We can drop the old > relfilenode immediately. But pg_class.relfilenode has to differ from the > old after the truncation. Why exactly? The first truncation in the (sub)xact would have assigned a new relfilenode, why do we need another one? The file in question will go away on crash/rollback in any case, and no other transaction can see it yet. I'm prepared to believe that some bit of logic is doing the wrong thing in this state, but I do not agree that truncate-in-place is unworkable. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers