Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jHWU4-00047y-P1 for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2020 17:40:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jHWU3-00051w-HX for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2020 17:39:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jHWU3-00051o-8R for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2020 17:39:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jHWU0-0000zN-BK for pgsql-hackers@postgresql.org; Thu, 26 Mar 2020 17:39:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02QHdqi0021558; Thu, 26 Mar 2020 13:39:52 -0400 From: Tom Lane To: Amit Langote cc: Pavel Stehule , PostgreSQL Hackers Subject: Re: plan cache overhead on plpgsql expression In-reply-to: References: <1478.1584815045@sss.pgh.pa.us> <11126.1585165468@sss.pgh.pa.us> Comments: In-reply-to Amit Langote message dated "Thu, 26 Mar 2020 19:56:32 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21556.1585244392.1@sss.pgh.pa.us> Date: Thu, 26 Mar 2020 13:39:52 -0400 Message-ID: <21557.1585244392@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Amit Langote writes: > One thing -- I don't get the division between > CachedPlanAllowsSimpleValidityCheck() and CachedPlanIsSimplyValid(). > Maybe I am missing something, but could there not be just one > function, possibly using whether expr_simple_expr is set or not to > skip or do, resp., the checks that the former does? Well, we don't want to do the initial checks over again every time; we want the is-valid test to be as simple and fast as we can make it. I suppose we could have one function with a boolean flag saying "this is a recheck", but I don't find that idea to be any better than the way it is. Also, although the existing structure in plpgsql always calls CachedPlanIsSimplyValid immediately after a successful call to CachedPlanAllowsSimpleValidityCheck, I don't think that's necessarily going to be true for other potential users of the functions. So merging the functions would reduce flexibility. regards, tom lane