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 1pPPv0-0002DN-Rq for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Feb 2023 15:30:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pPPuz-0005cP-O9 for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Feb 2023 15:30:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pPPuz-0005cG-Ex for pgsql-hackers@lists.postgresql.org; Tue, 07 Feb 2023 15:30:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pPPux-0003as-9x for pgsql-hackers@lists.postgresql.org; Tue, 07 Feb 2023 15:30:00 +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 317FTvTr3084886; Tue, 7 Feb 2023 10:29:57 -0500 From: Tom Lane To: Ronan Dunklau cc: pgsql-hackers@lists.postgresql.org Subject: Re: SQLFunctionCache and generic plans In-reply-to: <8216639.NyiUUSuA9g@aivenlaptop> References: <8216639.NyiUUSuA9g@aivenlaptop> Comments: In-reply-to Ronan Dunklau message dated "Tue, 07 Feb 2023 15:55:34 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3084884.1675783797.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 07 Feb 2023 10:29:57 -0500 Message-ID: <3084885.1675783797@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ronan Dunklau writes: > The following comment can be found in functions.c, about the SQLFunction= Cache: > * Note that currently this has only the lifespan of the calling query. > * Someday we should rewrite this code to use plancache.c to save parse/= plan > * results for longer than that. > I would be interested in working on this, primarily to avoid this proble= m of = > having generic query plans for SQL functions but maybe having a longer l= ived = > cache as well would be nice to have. > Is there any reason not too, or pitfalls we would like to avoid ? AFAIR it's just lack of round tuits. There would probably be some semantic side-effects, though if you pay attention you could likely make things better while you are at it. The existing behavior of parsing and planning all the statements at once is not very desirable --- for instance, it doesn't work to do CREATE TABLE foo AS ...; SELECT * FROM foo; I think if we're going to nuke this code and start over, we should try to make that sort of case work. regards, tom lane