Oracle檢視已被使用的open_cursors&session_cached_cursors
檢視當前session已使用的最大open cursor數 和cached cursor數:
SELECT 'session_cached_cursors' PARAMETER,
LPAD (VALUE, 5) VALUE,
DECODE (VALUE, 0, ' n/a', TO_CHAR (100 * USED / VALUE, '990') || '%')
USAGE
FROM (SELECT MAX (S.VALUE) USED
FROM V$STATNAME N, V$SESSTAT S
WHERE N.NAME = 'session cursor cache count'
AND S.STATISTIC# = N.STATISTIC#),
(SELECT VALUE
FROM V$PARAMETER
WHERE NAME = 'session_cached_cursors')
UNION ALL
SELECT 'open_cursors',
LPAD (VALUE, 5),
TO_CHAR (100 * USED / VALUE, '990') || '%'
FROM ( SELECT MAX (SUM (S.VALUE)) USED
FROM V$STATNAME N, V$SESSTAT S
WHERE N.NAME IN ('opened cursors current',
'session cursor cache count')
AND S.STATISTIC# = N.STATISTIC#
GROUP BY S.SID),
(SELECT VALUE
FROM V$PARAMETER
WHERE NAME = 'open_cursors');
注:如果查詢的session open cursor到達100% client就很可能報錯ORA-01000
檢視session open cursor的具體程式、open cursor數量:
SELECT a.inst_id,
a.sid,
a.USERNAME,
a.SCHEMANAME,
a.OSUSER,
a.machine,
a.TERMINAL,
a.LOGON_TIME,
a.PROGRAM,
a.STATUS,
b.name,
b.used
FROM gv$session a,
(SELECT n.inst_id,
sid,
n.name,
s.VALUE used
FROM gv$statname n, gv$sesstat s
WHERE n.name IN ('opened cursors current',
'session cursor cache count')
AND s.statistic# = n.statistic#
AND n.inst_id = s.inst_id) b
WHERE a.sid = b.sid
AND a.inst_id = b.inst_id
AND b.name <> 'session cursor cache count'
ORDER BY b.used DESC;
檢視session open cursor的具體SQL(此方法是聯合v$open_cursor得出的結果,可能有不準確。但session最多open_cursors的SQL一定是在執行結果中)
SELECT distinct a.inst_id,
a.sid,
a.USERNAME,
a.SCHEMANAME,
a.OSUSER,
a.machine,
a.TERMINAL,
a.LOGON_TIME,
a.PROGRAM,
a.STATUS,
b.name,
b.used,c.sql_id
FROM gv$session a,
(SELECT n.inst_id, sid, n.name, s.VALUE used
FROM gv$statname n, gv$sesstat s
WHERE n.name IN
('opened cursors current',
'session cursor cache count')
AND s.statistic# = n.statistic# and n.inst_id=s.inst_id ) b,v$open_cursor c
WHERE a.sid = b.sid and a.inst_id = b.inst_id and a.sid=c.sid and c.CURSOR_TYPE in('OPEN','OPEN-PL/SQL','OPEN-RECURSIVE')
and b.name <> 'session cursor cache count'
order by b.used desc;
SELECT 'session_cached_cursors' PARAMETER,
LPAD (VALUE, 5) VALUE,
DECODE (VALUE, 0, ' n/a', TO_CHAR (100 * USED / VALUE, '990') || '%')
USAGE
FROM (SELECT MAX (S.VALUE) USED
FROM V$STATNAME N, V$SESSTAT S
WHERE N.NAME = 'session cursor cache count'
AND S.STATISTIC# = N.STATISTIC#),
(SELECT VALUE
FROM V$PARAMETER
WHERE NAME = 'session_cached_cursors')
UNION ALL
SELECT 'open_cursors',
LPAD (VALUE, 5),
TO_CHAR (100 * USED / VALUE, '990') || '%'
FROM ( SELECT MAX (SUM (S.VALUE)) USED
FROM V$STATNAME N, V$SESSTAT S
WHERE N.NAME IN ('opened cursors current',
'session cursor cache count')
AND S.STATISTIC# = N.STATISTIC#
GROUP BY S.SID),
(SELECT VALUE
FROM V$PARAMETER
WHERE NAME = 'open_cursors');
注:如果查詢的session open cursor到達100% client就很可能報錯ORA-01000
檢視session open cursor的具體程式、open cursor數量:
SELECT a.inst_id,
a.sid,
a.USERNAME,
a.SCHEMANAME,
a.OSUSER,
a.machine,
a.TERMINAL,
a.LOGON_TIME,
a.PROGRAM,
a.STATUS,
b.name,
b.used
FROM gv$session a,
(SELECT n.inst_id,
sid,
n.name,
s.VALUE used
FROM gv$statname n, gv$sesstat s
WHERE n.name IN ('opened cursors current',
'session cursor cache count')
AND s.statistic# = n.statistic#
AND n.inst_id = s.inst_id) b
WHERE a.sid = b.sid
AND a.inst_id = b.inst_id
AND b.name <> 'session cursor cache count'
ORDER BY b.used DESC;
檢視session open cursor的具體SQL(此方法是聯合v$open_cursor得出的結果,可能有不準確。但session最多open_cursors的SQL一定是在執行結果中)
SELECT distinct a.inst_id,
a.sid,
a.USERNAME,
a.SCHEMANAME,
a.OSUSER,
a.machine,
a.TERMINAL,
a.LOGON_TIME,
a.PROGRAM,
a.STATUS,
b.name,
b.used,c.sql_id
FROM gv$session a,
(SELECT n.inst_id, sid, n.name, s.VALUE used
FROM gv$statname n, gv$sesstat s
WHERE n.name IN
('opened cursors current',
'session cursor cache count')
AND s.statistic# = n.statistic# and n.inst_id=s.inst_id ) b,v$open_cursor c
WHERE a.sid = b.sid and a.inst_id = b.inst_id and a.sid=c.sid and c.CURSOR_TYPE in('OPEN','OPEN-PL/SQL','OPEN-RECURSIVE')
and b.name <> 'session cursor cache count'
order by b.used desc;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25583515/viewspace-2152997/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 索引的使用情況檢視Oracle索引
- Oracle物化檢視的建立及使用(二)Oracle
- Oracle物化檢視的建立及使用(一)Oracle
- 如何檢視Oracle補丁 - opatch 的使用Oracle
- 檢視oracle資料庫的連線數以及使用者檢視Oracle資料庫
- 檢視ORACLE的使用者對錶的鎖的使用Oracle
- oracle隱藏引數的檢視和使用Oracle
- 檢視Oracle的表空間的使用情況Oracle
- Oracle 使用logmnr檢視日誌Oracle
- Oracle普通檢視和物化檢視的區別Oracle
- 檢視、修改oracle字符集,檢視oracle版本Oracle
- oracle 檢視使用者所在的表空間Oracle
- 詳解Oracle使用者許可權檢視的使用Oracle
- oracle 檢視錶空間使用情況Oracle
- Oracle檢視使用者許可權Oracle
- 檢視oracle表空間使用情況Oracle
- 檢視oracle 使用者許可權Oracle
- 使用opatch 命令檢視oracle patch 狀況Oracle
- 【Oracle】如何查詢檢視時使用索引Oracle索引
- Oracle常用的V$檢視Oracle
- 11、Oracle中的檢視Oracle
- Oracle檢視:常用動態效能檢視Oracle
- oracle效能檢視Oracle
- oracle檢視大全Oracle
- 管理oracle檢視Oracle
- oracle物化檢視Oracle
- 檢視Oracle使用者的許可權或角色Oracle
- Oracle物化檢視DBMS_MVIEW.EXPLAIN_MVIEW包的使用OracleViewAI
- oracle 檢視使用者密碼的修改時間Oracle密碼
- [Oracle] 檢視tablespace的使用率(Including temp tablespace)Oracle
- 【轉】檢視Oracle當前使用者下的資訊Oracle
- sql server 檢視tempdb使用的相關檢視SQLServer
- Oracle的V$檢視和DBA_檢視的參考提示Oracle
- 檢視oracle臨時表空間佔用率的檢視Oracle
- oracle-一些檢視效能相關的檢視Oracle
- Oracle 記憶體使用建議效能檢視Oracle記憶體
- 使用V$檢視觀察Oracle執行狀況Oracle
- ORACLE 程式的作用及檢視Oracle