Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltzIS-0002BP-Ka for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Jun 2021 21:11:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ltzIR-00048W-JS for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Jun 2021 21:11:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltzIR-00048O-Bv for pgsql-hackers@lists.postgresql.org; Thu, 17 Jun 2021 21:11:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltzIP-0007f4-Gx for pgsql-hackers@lists.postgresql.org; Thu, 17 Jun 2021 21:11:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15HLBQhr1059896; Thu, 17 Jun 2021 17:11:26 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@lists.postgresql.org Subject: Re: Centralizing protective copying of utility statements In-reply-to: <1057943.1623962182@sss.pgh.pa.us> References: <931771.1623893989@sss.pgh.pa.us> <20210617192300.7gkpqim43gk7ernd@alap3.anarazel.de> <1057943.1623962182@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 17 Jun 2021 16:36:22 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1059894.1623964286.1@sss.pgh.pa.us> Date: Thu, 17 Jun 2021 17:11:26 -0400 Message-ID: <1059895.1623964286@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > (In any case, if someone does get excited about this, they > could rearrange things to push the copyObject calls into the > individual arms of the switch in ProcessUtility. Personally > though I doubt it could be worth the code bloat.) It occurred to me to try making the copying code look like if (readOnlyTree) { switch (nodeTag(parsetree)) { case T_TransactionStmt: /* stmt is immutable anyway, no need to copy */ break; default: pstmt = copyObject(pstmt); parsetree = pstmt->utilityStmt; break; } } This didn't move the needle at all, in fact it seems maybe a shade slower: tps = 23502.288878 (without initial connection time) tps = 23643.821923 (without initial connection time) tps = 23082.976795 (without initial connection time) tps = 23547.527641 (without initial connection time) So I think this confirms my gut feeling that copyObject on a TransactionStmt is negligible. To the extent that the prior measurement shows a real difference, it's probably a chance effect of changing code layout elsewhere. regards, tom lane