Re: SQLFunctionCache and generic plans - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: SQLFunctionCache and generic plans
Date
Msg-id CAFj8pRA7MFTfUPwDDWtghaUvAjbrMHFUPbHyLSX3h8+FDw4WFg@mail.gmail.com
Whole thread Raw
In response to SQLFunctionCache and generic plans  (Ronan Dunklau <ronan.dunklau@aiven.io>)
Responses Re: SQLFunctionCache and generic plans
List pgsql-hackers
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




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Using Expanded Objects other than Arrays from plpgsql
Next
From: Tom Lane
Date:
Subject: Re: Better title output for psql \dt \di etc. commands