← Performance
Oracle · Performance

How to check total SGA and PGA memory in Oracle

One-row summary of Oracle SGA and PGA memory with a rollup grand total.

Tested on11g12c18c19c21c23ai26ai

Roll SGA (from V$SGA) and PGA (session pga memory from V$SESSTAT) up into a single tidy summary — three rows: sga, pga, and a grand total.

SELECT DECODE(GROUPING(nm), 1, 'total', nm) AS nm,
       ROUND(SUM(val / 1024 / 1024)) AS mb
FROM (
  SELECT 'sga' AS nm, SUM(value) AS val FROM v$sga
  UNION ALL
  SELECT 'pga', SUM(a.value)
  FROM   v$sesstat  a,
         v$statname b
  WHERE  b.name       = 'session pga memory'
  AND    a.statistic# = b.statistic#
)
GROUP BY ROLLUP(nm);
performancememorysgapgarollup