calling procedures is slow and consumes extra much memory againstcalling function
От | Pavel Stehule |
---|---|
Тема | calling procedures is slow and consumes extra much memory againstcalling function |
Дата | |
Msg-id | CAFj8pRDiiU1dqym+_P4_GuTWm76knJu7z9opWayBJTC0nQGUUA@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: calling procedures is slow and consumes extra much memory againstcalling function
Re: calling procedures is slow and consumes extra much memoryagainst calling function Re: calling procedures is slow and consumes extra much memory againstcalling function |
Список | pgsql-hackers |
Hi
I try to use procedures in Orafce package, and I did some easy performance tests. I found some hard problems:
1. test case
create or replace procedure p1(inout r int, inout v int) as $$
begin v := random() * r; end
$$ language plpgsql;
This command requires
do $$
declare r int default 100; x int;
begin
for i in 1..300000 loop
call p1(r, x);
end loop;
end;
$$;
declare r int default 100; x int;
begin
for i in 1..300000 loop
call p1(r, x);
end loop;
end;
$$;
about 2.2GB RAM and 10 sec.
When I rewrite same to functions then
create or replace function p1func2(inout r int, inout v int) as $$
begin v := random() * r; end
$$ language plpgsql;
begin v := random() * r; end
$$ language plpgsql;
do $$
declare r int default 100; x int; re record;
begin
for i in 1..300000 loop
re := p1func2(r, x);
end loop;
end;
$$;
declare r int default 100; x int; re record;
begin
for i in 1..300000 loop
re := p1func2(r, x);
end loop;
end;
$$;
Then execution is about 1 sec, and memory requirements are +/- zero.
Minimally it looks so CALL statements has a memory issue.
Regards
Pavel
В списке pgsql-hackers по дате отправления: