Wednesday, February 6, 2019

Get PGA used by session

SELECT DECODE(TRUNC(SYSDATE - LOGON_TIME), 0, NULL, TRUNC(SYSDATE - LOGON_TIME)
  || ' Days'
  || ' + ')
  || TO_CHAR(TO_DATE(TRUNC(MOD(SYSDATE-LOGON_TIME,1) * 86400), 'SSSSS'), 'HH24:MI:SS') LOGON,
  SID,
  v$session.SERIAL#,
  v$process.SPID ,
  ROUND(v$process.pga_used_mem/(1024*1024), 2) PGA_MB_USED,
  v$session.USERNAME,
  STATUS,
  OSUSER,
  MACHINE,
  v$session.PROGRAM,
  MODULE
FROM v$session,
  v$process
WHERE v$session.paddr = v$process.addr
ORDER BY pga_used_mem DESC;

To find the total PGA memory used by processes
SELECT ROUND(SUM(pga_used_mem)/(1024*1024),2) PGA_USED_MB FROM v$process;

To find PGA usage for a specific session
SELECT SID, b.NAME, ROUND(a.VALUE/(1024*1024),2) MB FROM 
v$sesstat a,  v$statname b
WHERE (NAME LIKE '%session uga memory%' OR NAME LIKE '%session pga memory%')
AND a.statistic# = b.statistic# 
AND SID =&SID

No comments:

Post a Comment