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 1tf4dg-00HFzE-Oj for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 22:09: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 1tf4cf-00H1n5-AG for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 22:08:53 +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 1tf4cf-00H1mx-0q for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 22:08:53 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tf4cc-0036ml-04 for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 22:08:52 +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 513M8jel464678; Mon, 3 Feb 2025 17:08:45 -0500 From: Tom Lane To: Pavel Stehule cc: Alexander Pyhalov , Alexander Korotkov , pgsql-hackers@lists.postgresql.org, Ronan Dunklau Subject: Re: SQLFunctionCache and generic plans In-reply-to: <445556.1738612687@sss.pgh.pa.us> 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> Comments: In-reply-to Tom Lane message dated "Mon, 03 Feb 2025 14:58:07 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <464676.1738620525.1@sss.pgh.pa.us> Date: Mon, 03 Feb 2025 17:08:45 -0500 Message-ID: <464677.1738620525@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > But wait: HEAD takes > Time: 6632.709 ms (00:06.633) > to do the same thing. So somehow the new-style SQL function > stuff is very materially slower in this use-case, with or > without this patch. I do not understand why. "perf" tells me that in the fx3 test, a full third of the runtime is spent inside stringToNode(), with about three-quarters of that going into pg_strtok(). This makes no sense to me: we'll be reading the prosqlbody of fx3(), sure, but that's not enormously long (about 1200 bytes). And pg_strtok() doesn't look remarkably slow. There's no way this should be taking more time than raw parsing + parse analysis, even for such a trivial query as "select $1 + $1". There's been some talk of getting rid of our existing nodetree storage format in favor of something more efficient. Maybe we should put a higher priority on getting that done. But anyway, that seems orthogonal to the current patch. > Even without cross-query plan caching, I don't see why the > patch isn't better than it is. It ought to be at least > competitive with the unpatched code. This remains true. regards, tom lane