0% found this document useful (0 votes)
29 views2 pages

Important Queries

The document contains a series of SQL queries designed to retrieve and analyze memory allocation and usage statistics from an Oracle database. It includes queries for shared pool size, SGA statistics, session counts, PGA memory usage, and hit ratios for database block gets. The queries provide insights into memory management and performance metrics within the database environment.

Uploaded by

cfmnizam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Important Queries

The document contains a series of SQL queries designed to retrieve and analyze memory allocation and usage statistics from an Oracle database. It includes queries for shared pool size, SGA statistics, session counts, PGA memory usage, and hit ratios for database block gets. The queries provide insights into memory management and performance metrics within the database environment.

Uploaded by

cfmnizam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

select value/1024/1024 shared_pool_size

from v$parameter
where name = 'shared_pool_size';

select * From v$sgastat;

select 'Memory Allocation' " "


, round(s.sgasize/1024/1024,2) "Total SGA (Mb)"
, round(f.bytes/1024/1024,2) " Free (Mb)"
, round(f.bytes*100/s.sgasize,2) " Free (%)"
from (select sum(bytes) sgasize from sys.v_$sgastat) s
, sys.v_$sgastat f
where f.name = 'free memory'

select round(used.bytes /1024/1024 ,2) used_mb


, round(free.bytes /1024/1024 ,2) free_mb
, round(tot.bytes /1024/1024 ,2) total_mb
from (select sum(bytes) bytes
from v$sgastat
where name != 'free memory') used
, (select sum(bytes) bytes
from v$sgastat
where name = 'free memory') free
, (select sum(bytes) bytes
from v$sgastat) tot

SELECT COUNT(*) FROM V$SESSION

SELECT SUM(PGA_USED_MEM) FROM V$PROCESS

SELECT COUNT(*) FROM V$SESSION

SELECT NAME, VALUE FROM V$PGASTAT WHERE NAME = 'process count'

select a.value, s.username, s.sid, s.serial#


from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current';

SELECT s.machine, oc.user_name, oc.sql_text, count(1)


FROM v$open_cursor oc, v$session s
WHERE oc.sid = s.sid
GROUP BY user_name, sql_text, machine
HAVING COUNT(1) > 2
ORDER BY count(1) DESC
;

select TRUNC((1-(phy.value/(cur.value + con.value)))*100,2) HIT_RATIO


from v$sysstat cur
, v$sysstat con
, v$sysstat phy
where cur.name = 'db block gets'
and con.name = 'consistent gets'
and phy.name = 'physical reads'
/

prompt
prompt ( 8i+ hit ratio )
-- hit ratio =
--
-- 1 - ( physical reads - (physical reads direct + physical reads direct
(lob)) )
--
--------------------------------------------------------------------------
-- ( db block gets + consistent gets - (physical reads direct + physical reads
direct (lob)) )
--

SELECT TRUNC(
(1 - (phy.value - (phyd.value + phydl.value)) /
(get.value + con.value - (phyd.value + phydl.value))
) * 100
,2) hit_ratio
FROM v$sysstat phy
, v$sysstat phyd
, v$sysstat phydl
, v$sysstat get
, v$sysstat con
WHERE phy.name = 'physical reads'
AND phyd.name = 'physical reads direct'
AND phydl.name = 'physical reads direct (lob)'
AND get.name = 'db block gets'
AND con.name = 'consistent gets'
/

You might also like