Re: Memory usage per session

From: AMatveev(at)bitec(dot)ru
To: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Memory usage per session
Date: 2016-07-08 14:29:54
Message-ID: 1682523257.20160708172954@bitec.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<html><head><title>Re: [GENERAL] Memory usage per session</title>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body>
<span style=" font-family:'Courier New'; font-size: 9pt;">Здравствуйте.<br>
<br>
&gt;&gt; Oracle: about 5M<br>
&gt;&gt; postgreSql: about 160М<br>
<br>
<br>
&gt;​I'm admittedly ignorant of this type of testing. But if the memory usage for PostgreSQL is in the server, perhaps due to caching (how to test?), then it likely would _not_ linearly scale up &gt;as the number of clients increased because every clients &gt;would share the same cache data within the server.​ Or are you measuring the memory usage where the client is on one machine and the &gt;PostgreSQL server is a different machine, with the client machine getting the memory hit?<br>
<br>
I can send zip file with test code on request;<br>
To say the truth it's described in documentation:<br>
https://www.postgresql.org/docs/9.5/static/plpgsql-implementation.html#PLPGSQL-PLAN-CACHING<br>
The PL/pgSQL interpreter parses the function's source text and produces an internal binary instruction tree the first time the function is called (within each session)&nbsp;<br>
<br>
It's very sad :(<br>
<br>
The test is very simply:<br>
Generate code:<br>
DECLARE<br>
&nbsp; svSql "varchar";<br>
BEGIN<br>
&nbsp; for nvi in 1..10<br>
&nbsp; loop<br>
&nbsp; &nbsp; svSql = 'CREATE OR REPLACE FUNCTION perfa."func'||nvi||'" (<br>
)<br>
RETURNS void AS<br>
$body$<br>
DECLARE<br>
&nbsp; svSql "varchar";<br>
BEGIN<br>
&nbsp; svSql:='''';<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+1||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+2||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+3||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+4||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+5||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+6||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+7||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+8||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+9||'"();<br>
&nbsp; PERFORM perfb."func'||(nvi-1)*10+10||'"(); &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>
END;<br>
$body$<br>
LANGUAGE ''plpgsql''<br>
VOLATILE<br>
CALLED ON NULL INPUT<br>
SECURITY INVOKER';<br>
&nbsp; &nbsp; EXECUTE svSql;<br>
&nbsp; end loop;<br>
END;<br>
<br>
Download jmetter<br>
In 50 thread run this funciton.<br>
<br>
<br>
About 4g memory will be consumed in one second&nbsp;<br>
It's hard to miss<br>
:))<br>
<br>
</body></html>

Attachment Content-Type Size
unknown_filename text/html 2.4 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2016-07-08 14:31:21 Re: Memory usage per session
Previous Message AMatveev 2016-07-08 14:07:00 Re: Memory usage per session