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 1tf0gQ-00GvXb-4x for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 17:56:30 +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 1tf0gO-00Feuq-S3 for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 17:56:28 +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 1tf0gO-00Feuh-IF for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 17:56:28 +0000 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tf0gL-0034mC-2Y for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 17:56:28 +0000 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-6f277a1ecfdso27783277b3.2 for ; Mon, 03 Feb 2025 09:56:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738605385; x=1739210185; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ZA246mFNJooHUr3zTVzBvHjxw5DnCyEXYt3f09EU1N4=; b=SZ3zeGVCiWc+N1IPBNMF+PnrYzQvxxUvIfRX0uF4WBSXr1csYm9Mzd7MaDj5otnYA1 I4lKPMgFBjwnT0zJ1dKaWrOPeiH7XdjRjSiTtBBdF8gUO87bSQjMuK++F+LIeWGDXouY OPAY9QlchsjHqRiS9kyXseIOKzkOM/X+UJUiWHqQyMgsSHgiIIamHj8vr37lhPWxwX0U z9hhkUcT0I/2Mjfz4909EBJ2w7xbOIpL/R/9pSozaPEUV4TBhVpRdd1kdILX6Amrk0g7 bV628eCjgb8X5zF5oDZJ3I6Gf//uVbxBZj/WUkAo+FD9woz6FRAzs6zqB67VZjG9IwfE fdvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738605385; x=1739210185; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZA246mFNJooHUr3zTVzBvHjxw5DnCyEXYt3f09EU1N4=; b=CKFEE7il27GPsQB1oKeTOlb7XyNlTBjnMG2N5vyKg0JBs72ZhdGArrXv37bWJVht3v sIfytlMyNIaxypzkkYhXxPSr0G4aFTruP+sy6RJvdxG0tquRtSgdJHHGuCKTxYT/l5Lc Ghp+YOTZFiSevuEz6OhWJTg7pOq4wDYw/UB3kwRIyAGho4SGAHxiXgULg+J4nVRN4BAh cklGzGGjzIefSTbQwwNU02fDDwIi6CyfDQmSmEI3VjLZidTlr3yG9yVX+bdiayN+5bYf HMwQOH8clO8l4Q7DM0mxOZM1FCDRqAUcV/Ku6bJ7BymQNCXRMXBbUj7yjuKXQVj0b7cF 6sqA== X-Forwarded-Encrypted: i=1; AJvYcCUON0txiK8kgCBCsIQ5FinPx+AmC+dtllz4aV5yQ+KsQNwVpthd4CQ5RESJB2bI6QdK8PFFhWsOT/hbznRR@lists.postgresql.org X-Gm-Message-State: AOJu0YzH1+7BU1rfX/EnYfqOKQMGRhavL+88TiPVVIY9QYRn/hs0HzOM PVfJEhac6oUto6fTPTrNOODOBppR+BTkLGz6ru4hjaCEHKTD0akdU0AYXNCKKYfOg8DifS5xmwJ yN6L+a+YBpef+PGd1PMH0SDu17Mw= X-Gm-Gg: ASbGncsPMMvUDMe1bncJedpM7Nv4CeDAfn69SnKx9buvOSCXHCmLHCc4qP+yNQNW5Yb W+sZdkOuCJ9uuKxWmKKNrp1oSP5n8lu4hniHSiQnCwjcFaBPWyGwfefN5oFZrxfaOcANuXoD0D2 dNMjbiL8f2oTyRV8NPwmVSbQ4MCS7CIg== X-Google-Smtp-Source: AGHT+IG5Y21DU+Rr5KXiT4pYfRYFjWnvA5irC0R7nsOhnNTaF9i/pPaKC0TrAjCJQ57oZH/MnIWf3rhXFsciSeAMlik= X-Received: by 2002:a05:690c:6e07:b0:6ef:6cdd:57e3 with SMTP id 00721157ae682-6f7a832a3damr165085047b3.8.1738605384853; Mon, 03 Feb 2025 09:56:24 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: From: Pavel Stehule Date: Mon, 3 Feb 2025 18:55:48 +0100 X-Gm-Features: AWEUYZn8BfDtRnwcD3Ld3aAcvTaZPizdXkuVJFEurxhp6zvhGlpptvjolTdTAwE Message-ID: Subject: Re: SQLFunctionCache and generic plans To: Tom Lane Cc: Alexander Pyhalov , Alexander Korotkov , pgsql-hackers@lists.postgresql.org, Ronan Dunklau Content-Type: multipart/alternative; boundary="0000000000005e7177062d409ccd" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005e7177062d409ccd Content-Type: text/plain; charset="UTF-8" Hi I did multiple benchmarking, and still looks so the proposed patch doesn't help and has significant overhead testcase: create or replace function fx(int) returns int as $$ select $1 + $1; $$ language sql immutable; create or replace function fx2(int) returns int as $$ select 2 * $1; $$ language sql immutable; I tested do $$ begin for i in 1..1000000 loop perform fx((random()*100)::int); -- or fx2 end loop; end; $$; Results (master, patched): fx: 17067 ms, 22165 ms fx2: 2234 ms, 2311 ms the execution of dynamic sql 2025-02-03 18:47:33) postgres=# do $$ begin for i in 1..1000000 loop execute 'select $1 + $1' using (random()*100)::int; end loop; end; $$; DO Time: 13412.990 ms (00:13.413) In the profiler I see a significant overhead of the parser, so it looks like there is some more (overhead), but plan cache is not used. Please, can somebody recheck my tests? Regards Pavel --0000000000005e7177062d409ccd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

I did multiple benchmarki= ng, and still looks so the proposed patch doesn't help and has signific= ant overhead

testcase:

create or replace function fx(int) returns int as $$ select $1 + $1; $$ = language sql immutable;
create or replace function fx2(int)= returns int as $$ select 2 * $1; $$ language sql immutable;

=
I tested

do $$ =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0
begin
=C2=A0 for i in 1..1000000 loop
= =C2=A0 =C2=A0 perform fx((random()*100)::int); -- or fx2
=C2=A0 end loop= ;
end;
$$;

Results (master, patched):
<= div>fx: 17067 ms, 22165 ms
fx2: 2234 ms, 2311 ms

the execution of dynamic sql

2025-02-03 1= 8:47:33) postgres=3D# do $$
begin
=C2=A0 for i in 1..1000000 loop
= =C2=A0 =C2=A0 execute 'select $1 + $1' using (random()*100)::int;=C2=A0 end loop;
end;
$$;
DO
Time: 13412.990 ms (00:13.413)

In the profiler I see a significant overhead of the= parser, so it looks like there is some more (overhead), but plan cache is = not used.

Please, can somebody recheck my tests?

Regards

Pavel




--0000000000005e7177062d409ccd--