Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Find how much memory is postgres using

33 views
Skip to first unread message

Nik Tek

unread,
Apr 7, 2013, 12:59:16 AM4/7/13
to
Hi,

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

Thank you
NikT

Yetkin Öztürk

unread,
Apr 7, 2013, 3:15:39 AM4/7/13
to
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.



2013/4/7 Nik Tek <nikte...@gmail.com>

hubert depesz lubaczewski

unread,
Apr 8, 2013, 6:18:03 AM4/8/13
to
On Sun, Apr 07, 2013 at 09:27:42PM -0700, Nik Tek wrote:
> 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-pe...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Nik Tek

unread,
Apr 9, 2013, 2:24:22 PM4/9/13
to
--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

hubert depesz lubaczewski

unread,
Apr 9, 2013, 2:34:07 PM4/9/13
to
On Tue, Apr 09, 2013 at 11:24:22AM -0700, Nik Tek wrote:
> --For MSSQL
> select
...
> -- 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 :)

Nik Tek

unread,
Apr 9, 2013, 2:42:19 PM4/9/13
to
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
0 new messages