Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w7C6S-0053RE-0O for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 12:52:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7C6Q-003IwY-16 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 12:52:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w7C6Q-003IwP-0B for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 12:52:22 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w7C6N-00000001zi6-29VF for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 12:52:22 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 71D46EC00A9; Mon, 30 Mar 2026 08:52:18 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Mon, 30 Mar 2026 08:52:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1774875138; x=1774961538; bh=f6RsQP7LfY MkP5cX7+8SxZQXXl2Pjtw00D7AgZPzXa8=; b=kIIGetzndGoGUnyvSF81qbWFe2 i4mXVjtOcFN6ZqkqFgC2GF5ej13YZ5jH7j3uJcd12JctoRN9NlRrmZmg4YLrYRSN SGU8+IZZCw5JD06utY4czjiGsVS7hldJJIwGOF9UOWiT3Ju4Duq76stZ9cfzoymS TUX8y1Z/heFCybbA8PWfdQQTyeiLPRoaLVjd0VRFTxNNCRR6fw0FRFpXsXUKg0sk Gr1G8j62ur5nIfKLLDN/2qB4RWbastJf4R2OzNG61GrLYU2/ApQEmErS/91w6Onh YrU8NzcNs2QzihwIIY1Zh+6dAADXaMj4JbTR0/+Hn9kNgNL2lFOgLTRElNHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1774875138; x=1774961538; bh=f6RsQP7LfYMkP5cX7+8SxZQXXl2Pjtw00D7 AgZPzXa8=; b=H3kVNZh3fjLBcxh4QkVZdsa+W1Aatc+OoP/r5Y2XVQr+vmxnDNs PYHizc+eAewvdUxdygVBfwDdMKDYaUPAM666HMmNZ8iJoP2XXbKvgsA7BFrhphoW jZ16gCrVvEadTC0LVAQ7BthR1IWEIww3QBEKQonvlvm9rpbkSxXMcwHcju9hHYnm U45VwGIqoylBQmWTFR9LX29cIGFQSJH6IW5nKKMXF3hYhN5ounTaivVmt52Je4/j Coad7y+bUe8EHzkeVp48DGfxzOOCe9Y6ctV5adMTBFaaP41X8oAp0eLO4fg6WDZl G1Glt4DPv+t7njxEOEtQ3lqYBkIAKEkY6aQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdeffeeltddvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtsfdttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepfeffgfelvdffgedtveelgfdtgefghfdvkefggeetieevjeekteduleevjefh ueegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopedvpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopeefuggrnhhishhsihhmohesghhmrghilhdrtghomh dprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgv shhqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Mar 2026 08:52:17 -0400 (EDT) Date: Mon, 30 Mar 2026 08:52:17 -0400 From: Andres Freund To: Daniil Davydov <3danissimo@gmail.com> Cc: Postgres hackers Subject: Re: Get rid of redundant StringInfo accumulation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-03-29 19:26:11 +0700, Daniil Davydov wrote: > I have noticed that there are several places in the code where we are > creating StringInfo in order to log its content. But this work may be wasted > if the specified log level is not interesting both for client and server. > I.e. now we can allocate memory for StringInfo which will never be displayed. > > I think that at first we should check whether log level is interesting and > only then start creating the StringInfo. > > Please, see the attached patch that fixes it. I hope I have found all the > places where it would be appropriate. I don't see when the overhead of creating an populating the string info ever matters in these cases. This is optimizing something that never can matter for real world performance. Even if it were worth optimizing them, I doubt that the log level check is useful here, because most if not all of these are logged with a level that's logged in nearly all installations. Greetings, Andres Freund