Memory utilization on Oracle database

use following query to calculate the memory used by the each session:

set lines 375 pages 375
col session for a45
SELECT to_char(ssn.sid, '9999') || ' - ' || nvl(ssn.username, nvl(bgp.name, 'background')) ||
nvl(lower(ssn.machine), ins.host_name) "SESSION",
ssn.username,
ssn.status,
to_char(prc.spid, '999999999') "PID/THREAD",
to_char((se1.value/1024)/1024, '999G999G990D00') || ' MB' " CURRENT SIZE",
to_char((se2.value/1024)/1024, '999G999G990D00') || ' MB' " MAXIMUM SIZE"
FROM v$sesstat se1, v$sesstat se2, v$session ssn, v$bgprocess bgp, v$process prc,
v$instance ins, v$statname stat1, v$statname stat2
WHERE se1.statistic# = stat1.statistic# and stat1.name = 'session pga memory'
AND se2.statistic# = stat2.statistic# and stat2.name = 'session pga memory max'
AND se1.sid = ssn.sid
AND se2.sid = ssn.sid
AND ssn.paddr = bgp.paddr (+)
AND ssn.paddr = prc.addr (+) 
order by ssn.status;

===

col a heading "Current UGA|size for the session'
col b heading "Current PGA|size for the session'

select
   e.sid,
   e.username,
   e.status,
   a.uga_memory,
   b.pga_memory
from
 (select y.SID, 
  TO_CHAR(ROUND(y.value/1024),99999999) || ' KB' UGA_MEMORY 
  from 
     v$sesstat y, 
     v$statname z 
   where 
     y.STATISTIC# = z.STATISTIC# 
   and 
     NAME = 'session uga memory') a,
 (select 
     y.SID, 
     TO_CHAR(ROUND(y.value/1024),99999999) || ' KB' PGA_MEMORY   
  from 
     v$sesstat y, v$statname z 
  where 
     y.STATISTIC# = z.STATISTIC#   
  and 
     NAME = 'session pga memory') b,
v$session e
where
   e.sid=a.sid 
and 
   e.sid=b.sid 
order by
   e.status,
   a.uga_memory desc;
   
   
   
select
   s.sid,
   pmd.category,
   pmd.name,
   pmd.heap_name,
   pmd.bytes,
   pmd.allocation_count
from
   v$session               s,
   v$process               p,
   v$process_memory_detail pmd
where
   s.paddr = p.addr
and 
   p.pid = pmd.pid
and 
   p.spid IN (&1)
order by
   sid,
   spid,
   bytes DESC;

====

select
to_number(decode(SID, 65535, NULL, SID)) SID,
   operation_type                OPERATION,
   trunc(WORK_AREA_SIZE/1024)    WSIZE, 
   trunc(EXPECTED_SIZE/1024)     ESIZE,
   trunc(ACTUAL_MEM_USED/1024)   MEM, 
   trunc(MAX_MEM_USED/1024)      "MAX MEM", 
   number_passes                 PASS
from
   v$sql_workarea_active
order by
   1,2;

Comments

Popular posts from this blog

Profile password verify function issue - From root

Change character set of Oracle database and using CSSAN and DMU

Upload patch to OEM (12c/13c)