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 1tyWrp-007wdI-HC for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Mar 2025 14:08:57 +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 1tyWro-00BRpb-9A for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Mar 2025 14:08:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tyWrn-00BRnM-Vu for pgsql-hackers@lists.postgresql.org; Sat, 29 Mar 2025 14:08:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tyWrm-001o6E-10 for pgsql-hackers@lists.postgresql.org; Sat, 29 Mar 2025 14:08:55 +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 52TE8n7q2691108; Sat, 29 Mar 2025 10:08:49 -0400 From: Tom Lane To: Alexander Pyhalov cc: Pavel Stehule , Alexander Korotkov , pgsql-hackers@lists.postgresql.org, Ronan Dunklau Subject: Re: SQLFunctionCache and generic plans In-reply-to: References: <8216639.NyiUUSuA9g@aivenlaptop> <3084885.1675783797@sss.pgh.pa.us> <758251661a3e8760ff52dd5c672a7505@postgrespro.ru> <30f02ca545915627905fbe3f23d93ec1@postgrespro.ru> <2275997.1737138456@sss.pgh.pa.us> <51ebc5f3b846ce279b75ac4f5e5ac33f@postgrespro.ru> <401652.1738598448@sss.pgh.pa.us> <445556.1738612687@sss.pgh.pa.us> <464677.1738620525@sss.pgh.pa.us> <1fc18af56d5fb27bf3e153ffaa2ed70d@postgrespro.ru> <2615770.1740688857@sss.pgh.pa.us> <448c63cf9b4f917c01802309b9c29eb9@postgrespro.ru> <2827970.1741890560@sss.pgh.pa.us> <337e011069b6831e063bfa346f49bb46@postgrespro.ru> <3344719.1741985546@sss.pgh.pa.us> Comments: In-reply-to Alexander Pyhalov message dated "Sat, 29 Mar 2025 10:24:41 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2691106.1743257329.1@sss.pgh.pa.us> Date: Sat, 29 Mar 2025 10:08:49 -0400 Message-ID: <2691107.1743257329@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexander Pyhalov writes: > After writing some comments, looking at it once again, I've found that > one assumption is wrong - function can be discarded from cache during > its execution. Yeah. You really need a use-count on the shared cache object. I've been working on pulling out plpgsql's code that manages its function cache into a new module that can be shared with functions.c. That code is quite battle-tested and I don't see a good argument for reinventing the logic. It's not fit to share yet, but I hope to have something in a day or so. > Also one interesting note is as we don't use raw_parse_tree, it seems we > don't need plansource->parserSetup and plansource->parserSetupArg. It > seems we can avoid caching complete parse info. Well, you do need those when dealing with an old-style function (raw parse trees). regards, tom lane