Discussion:
Find how much memory is postgres using
(too old to reply)
Nik Tek
2013-04-07 04:59:16 UTC
Permalink
Hi,

Could someone tell m how to measure postgres memory usage.
Is there a pg_* view to measure?

Thank you
NikT
Yetkin Öztürk
2013-04-07 07:15:39 UTC
Permalink
Hi,
as you know 'memory usage' is smt continuously changes in time and not
directly related to pg also related to your resources , you can set a
specific limit if you want.
Post by Nik Tek
Hi,
Could someone tell m how to measure postgres memory usage.
Is there a pg_* view to measure?
Thank you
NikT
hubert depesz lubaczewski
2013-04-08 10:18:03 UTC
Permalink
Thank you Depesz!
But I have a naive question, why isn't a straight forword approach for
postgres, unlike Oracle or MSSQL?
No idea. And how do you get memory usage in Oracle or MSSQL?

Best regards,

depesz
--
Sent via pgsql-performance mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
Nik Tek
2013-04-09 18:24:22 UTC
Permalink
--For MSSQL
select
(select cntr_value
from sys.dm_os_performance_counters
where object_name like '%Memory Manager%' and counter_name like
'Maximum Workspace Memory (KB)%') as Maximum_Workspace_Memory_KB,
(select cntr_value
from sys.dm_os_performance_counters
where object_name like '%Memory Manager%' and counter_name like
'Target Server Memory (KB)%') as Target_Server_Memory_KB,
(select cntr_value
from sys.dm_os_performance_counters
where object_name like '%Memory Manager%' and counter_name like
'Maximum Workspace Memory (KB)%') * 100.0
/
(select cntr_value
from sys.dm_os_performance_counters
where object_name like '%Memory Manager%' and counter_name like
'Target Server Memory (KB)%') as Ratio

-- Oracle
SELECT sum(bytes)/1024/1024
FROM v$sgastat;

Thank you
Nik
Post by hubert depesz lubaczewski
Thank you Depesz!
But I have a naive question, why isn't a straight forword approach for
postgres, unlike Oracle or MSSQL?
No idea. And how do you get memory usage in Oracle or MSSQL?
Best regards,
depesz
hubert depesz lubaczewski
2013-04-09 18:34:07 UTC
Permalink
Post by Nik Tek
--For MSSQL
select
...
Post by Nik Tek
-- Oracle
...

Well, the answer is simple - in Microsoft and Oracle, someone wrote such
views/functions. In Pg - not. You are welcome to provide a patch,
though :)

Best regards,

depesz
--
Sent via pgsql-performance mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
Nik Tek
2013-04-09 18:42:19 UTC
Permalink
Hi Depesz,

--Here is better one for Oracle by sga/pga.
SELECT DECODE (GROUPING (nm), 1, 'total', nm) nm,
ROUND (SUM (val / 1024 / 1024)) MB
FROM (SELECT 'sga' nm, SUM (VALUE) val FROM v$sga
UNION ALL
SELECT 'pga', SUM (VALUE)
FROM v$sysstat
WHERE name = 'session pga memory')
GROUP BY ROLLUP (nm);

Sure, I will take up the task, will send you the script once it is ready,
so you can bless it. :)

Regards
Nik




On Tue, Apr 9, 2013 at 11:34 AM, hubert depesz lubaczewski <
Post by hubert depesz lubaczewski
Post by Nik Tek
--For MSSQL
select
...
Post by Nik Tek
-- Oracle
...
Well, the answer is simple - in Microsoft and Oracle, someone wrote such
views/functions. In Pg - not. You are welcome to provide a patch,
though :)
Best regards,
depesz
Loading...