PGA,sga命中sql查詢

germany006發表於2014-02-23

經常忘記,記錄這裡,以便備查:

PGA的記憶體命中:

SELECT name profile,cnt,decode( total, 0, 0, round( cnt * 100 / total)) percentage
FROM ( SELECT name, value cnt, ( SUM( value ) OVER()) total
FROM v$sysstat
WHERE name LIKE 'workarea exec%');

-- 資料緩衝區快取記憶體
SELECT physical_reads, db_block_gets, consistent_gets, NAME,
100 * ( 1 - ( physical_reads / (consistent_gets + db_block_gets - physical_reads))) "Data Buffer Hit Ratio"
FROM v$buffer_pool_statistics;

-- 重做日至緩衝區
SELECT a.VALUE redo_entries, b.VALUE redo_buffer_allocation_retries,
ROUND ((1 - b.VALUE / a.VALUE) * 100, 4) log_buffer_ratio
FROM v$sysstat a, v$sysstat b
WHERE a.NAME = 'redo entries' AND b.NAME = 'redo buffer allocation retries';

-- 資料字典快取記憶體
SELECT SUM (pinhits) / SUM (pins) * 100 "hit radio"
FROM v$librarycache;

-- 庫快取記憶體
SELECT TO_CHAR (ROUND ((1 - SUM (getmisses) / SUM (gets)) * 100, 1)) || '%' "Dictionary Cache Hit Ratio"
FROM v$rowcache;

-- 排序
SELECT a.VALUE disk_sort, b.VALUE memory_sort, ROUND ((1 - a.VALUE / (a.VALUE + b.VALUE)) * 100, 4) sort_ratio
FROM v$sysstat a, v$sysstat b
WHERE a.NAME = 'sorts (disk)' AND b.NAME = 'sorts (memory)';

--找出相關的sql根據系統pid
select se.username,se.machine,sq.cpu_time,sq.sql_text from
v$process p,v$session se,v$sqlarea sq
where p.addr=se.paddr and se.sql_hash_value=sq.hash_value and p.addr='&pid';

列出cpu_time top 10

select cpu_time,sql_text
from (select sql_text,cpu_time,
rank() over (order by cpu_time desc) exec_rank
from v$sql
)
where exec_rank <=10;


執行次數最多的top 10
select sql_text,executions
from (select sql_text,executions,
rank() over
(order by executions desc) exec_rank
from v$sql)
where exec_rank <=10;


ora

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28371090/viewspace-1086558/,如需轉載,請註明出處,否則將追究法律責任。

相關文章