| From: | happy times <guangzhouzhang(at)qq(dot)com> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Cc: | 德哥 <digoal(at)126(dot)com> |
| Subject: | Unexpected memory usage for repeated inserts within plpgsql function |
| Date: | 2016-07-21 10:39:20 |
| Message-ID: | tencent_5C738ECA65BAD6861AA43E8F@qq.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Hackers,
I have been seeing memory usage increasing for a simple plpgsql function. Could you please take a look and check is it a bug?
The function definition is:
create function f() returns int as
$$DECLARE count int;
BEGIN
count := 1;
LOOP
count := count + 1;
begin
EXECUTE 'insert into test values(10)';
IF count > 1000000 THEN
EXIT;
END IF;
exception when others then
end;
END LOOP;
END$$
LANGUAGE plpgsql;
When I ran this function by "select f()", from top command, I could see memory usage (Resident memory) kept on increasing:
Then I used gdb to suspend the process each time insert was actually executed, and issued " (gdb) p MemoryContextStats(TopMemoryContext) ". From the server log, I saw only "SPI Proc" part of all the memory contexts was increasing:
My question: Is this problem as-designed?
Thank you for your time!!
Guangzhou
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jim Mlodgenski | 2016-07-21 13:21:55 | Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE |
| Previous Message | Kyotaro HORIGUCHI | 2016-07-21 09:52:49 | Re: [BUG] pg_basebackup from disconnected standby fails |