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.94.2) (envelope-from ) id 1u56Xn-00CJhl-9A for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Apr 2025 17:27:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u56Xj-001Swa-Cn for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Apr 2025 17:27:24 +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.94.2) (envelope-from ) id 1u56Xj-001Svv-2X for pgsql-hackers@lists.postgresql.org; Wed, 16 Apr 2025 17:27:23 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u56Xf-000Qc6-1u for pgsql-hackers@lists.postgresql.org; Wed, 16 Apr 2025 17:27:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2025010100; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description; bh=50oCgjXItN+1xnOS8fBFioNhrDw8ZxkBvIlIJ+7khBI=; b=EZD4EhEhp5Z0bBVaMmMj+E5Bta 7Vbb98w8rn4mQD3z/uJiM3o0HxDJ0Ji8x3nqtUhl3FVgtchP/G9Gam05KMurFbKzQ4OaOIba9NgJQ 7WMwmu9P1iixbq2mVKTLWWKAITdvMVLjqYROfHhGcRZFmuSmB8JiCmWQnVjLsDadmmYt3y5RKqsDY 7Ij15oOzEz6xHhnKnblRjFafpEC5jiH/otECFFSd6h1npSdwaZ6AqIcgpF+ZvOfk5Y0Og0gDjKfWd Acb1zbFiWd6GLLbjKAungyjWsCdBvmIDO9LfEyUHPgN79bxKdJlc71gF/guzqstlfbYEIgXqD7xTc SRJ0KNHA==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1u56Xd-0078N2-2Y; Wed, 16 Apr 2025 13:27:17 -0400 Date: Wed, 16 Apr 2025 13:27:17 -0400 From: Bruce Momjian To: Robert Haas Cc: Tom Lane , pgsql-hackers@lists.postgresql.org, Alexander Pyhalov , Pavel Stehule Subject: Re: Performance issues with v18 SQL-language-function changes Message-ID: References: <1112592.1744572204@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 14, 2025 at 10:38:29AM -0400, Robert Haas wrote: > On Sun, Apr 13, 2025 at 3:23 PM Tom Lane wrote: > > create function fx(p_summa bigint) returns text immutable strict > > return ltrim(to_char(p_summa, '999 999 999 999 999 999 999 999')); > > > > explain analyze select fx(i) from generate_series(1,1000000) as i(i); > > > > you arrive at the rude discovery that 0dca5d68d is about 50% slower > > than 0dca5d68d^, because the old implementation builds a plan for fx() > > only once and then re-uses it throughout the query. > > I agree that we should do something about this. I haven't reviewed > your patches but the approach sounds broadly reasonable. Yep, we went down the road in PG 18 to convert syntax, and now we have to fix this, or we have to revert all the PG 18 syntax changes, which seems like a step backward. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Do not let urgent matters crowd out time for investment in the future.