檢視會話記憶體占用情況
select server "連線型別",
s.username,
osuser,
name,
value/1024/1024 "占用記憶體mb",
s.sid "會話id",
s.serial#,
spid "作業系統程序id",
p.pga_used_mem,
p.pga_alloc_mem,
p.pga_freeable_mem,
p.pga_max_mem
from v$session s, v$sesstat st, v$statname sn, v$process p
where st.sid = s.sid
and st.statistic# = sn.statistic#
and sn.name like 'session pga memory'
and p.addr = s.paddr
order by value desc
如果想殺死指定會話alter system kill session 'sid,serial#';,記憶體沒有釋放執行如下步驟;
select a.spid,b.sid,b.serial#,b.username from v$process a,v$session b where a.addr=b.paddr and b.status='killed' ;
檢視killed狀態的會話,
windows下:orakill.exe orcl spid,其中orcl是資料庫的sid,spid是上面查詢出來的
linux下:kill -9 spid;
sql消耗資源情況查詢:
從v$sqlarea中查詢最占用資源的查詢
select b.username username,a.disk_reads reads,
a.executions exec,a.disk_reads/decode(a.executions,0,1,a.executions) rds_exec_ratio,
a.sql_text statement
from v$sqlarea a,dba_users b
where a.parsing_user_id=b.user_id
and a.disk_reads > 100000
order by a.disk_reads desc;
用buffer_gets列來替換disk_reads列可以得到占用最多記憶體的sql語句的相關資訊。
v$sql是記憶體共享sql區域中已經解析的sql語句。
列出使用頻率最高的5個查詢
select sql_text,executions
from (select sql_text,executions,
rank() over
(order by executions desc) exec_rank
from v$sql)
where exec_rank <=5;
消耗磁碟讀取最多的sql top5
select disk_reads,sql_text
from (select sql_text,disk_reads,
dense_rank() over
(order by disk_reads desc) disk_reads_rank
from v$sql)
where disk_reads_rank <=5;
找出需要大量緩衝讀取(邏輯讀)操作的查詢
select buffer_gets,sql_text
from (select sql_text,buffer_gets,
dense_rank() over
(order by buffer_gets desc) buffer_gets_rank
from v$sql)
where buffer_gets_rank<=5;
時間占用多的:
select s.sql_text,
s.sql_fulltext,
s.sql_id,
round(elapsed_time / 1000000 / (case
when (executions = 0 or nvl(executions, 1) = 1) then
1else
executions
end),
2) "執行時間's'",
s.executions "執行次數",
s.optimizer_cost "cost",
s.sorts,
s.module, --連線模式(jdbc thin client:程式)
-- s.locked_total,
--s.physical_read_bytes "物理讀",
-- s.physical_read_requests "物理讀請求",
--s.physical_write_requests "物理寫",
-- s.physical_write_bytes "物理寫請求",
s.rows_processed "返回行數",
s.disk_reads "磁碟讀",
s.direct_writes "直接路徑寫",
s.parsing_schema_name,
s.last_active_time
from **$sqlarea s
where round(elapsed_time / 1000000 / (case
when (executions = 0 or nvl(executions, 1) = 1) then
1else
executions
end),
2) > 5 --100 0000微秒=1s
and s.parsing_schema_name = user
and to_char(s.last_load_time, 'yyyy-mm-dd') =
to_char(sysdate, 'yyyy-mm-dd')
and s.command_type in (2, 3, 5, 6, 189)
order by "執行時間's'" desc;
Linux 記憶體使用情況
linux系統如何檢視使用記憶體情況 root r2 free total used free shared buffers cached mem 215608 142680 72928 0 19736 86956 buffers cache 35988 179620 swap 1052248 0 ...
檢視記憶體使用情況
查詢sqlserver總體的記憶體使用情況select type sum virtual memory reserved kb vm reserved sum virtual memory committed kb vm commited sum awe allocated kb awe alloc...
LINUX 記憶體使用情況
顯示結果如下 mem 表示物理記憶體統計 total 記憶體總數 8057964kb used 已使用的記憶體 7852484kb free 空閒的記憶體數 205480kb shared 當前已經廢棄不用,總是0 buffers buffer 快取記憶體數 290432kb cached page...