How to show how much PGA is used by an SQl statement in Oracle database:
select s.sid, s.username, s.osuser, s.sql_id, s.logon_time, s.program, PGA_USED_MEM/1024/1024 PGA_USED_MEM, PGA_ALLOC_MEM/1024/1024 PGA_ALLOC_MEM from v$session s, v$process p Where s.paddr = p.addr and PGA_USED_MEM/1024/1024 > 20 order by PGA_USED_MEM;
How to show the highest PGA usage:
select s.osuser osuser,s.serial# serial,se.sid,n.name,
max(se.value)/1024/1024 mem_mb
from v$sesstat se,
v$statname n,
v$session s
where n.statistic# = se.statistic#
and n.name in ('session pga memory','session pga memory max',
'session uga memory','session uga memory max')
and s.sid=se.sid
and s.sid = (select sid from v$session --where username = '<username>' and OSUSER = '<myOSusername>'
)
group by n.name,se.sid,s.osuser,s.serial#
order by 2;
