Thread: Find how much memory is postgres using
Hi,
Could someone tell m how to measure postgres memory usage.
Is there a pg_* view to measure?
Thank you
NikT
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 <niktek2005@gmail.com>
Hi,Could someone tell m how to measure postgres memory usage.Is there a pg_* view to measure?Thank youNikT
On Sat, Apr 06, 2013 at 09:59:16PM -0700, Nik Tek wrote: > Could someone tell m how to measure postgres memory usage. > Is there a pg_* view to measure? http://www.depesz.com/2012/06/09/how-much-ram-is-postgresql-using/ Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/
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
--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
On Mon, Apr 8, 2013 at 3:18 AM, hubert depesz lubaczewski <depesz@depesz.com> wrote:
On Sun, Apr 07, 2013 at 09:27:42PM -0700, Nik Tek wrote:No idea. And how do you get memory usage in Oracle or MSSQL?
> Thank you Depesz!
> But I have a naive question, why isn't a straight forword approach for
> postgres, unlike Oracle or MSSQL?
Best regards,
depesz
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 :) Best regards, depesz
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 <depesz@depesz.com> wrote:
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 :)
Best regards,
depesz