OWI -- 用 logoff trigger 保留每個 session 的效能資訊
如果某個開發人員跟你說他的程式最近跑得很慢,你問他做了什麼修改,他說沒有。你說能不能跑給你看一下,他說程式只在每天凌晨跑。這時候收集每個session的效能歷史資訊就很重要。
event 10046對於不確定的session,收集資訊太多,成本太高。
statspack缺乏追蹤每一個資料庫連線的功能。
用l ogoff trigger 是個不錯的選擇,該 trigger 會在每個 session 正常退出時自動觸發。指令碼如下,可根據具體情況作適當修改。
--from <
--建立表
-------------------------------
--
-- Create table
-- SESSION_EVENT_HISTORY
--
-------------------------------
create table session_event_history
as
select b.sid,
b.serial#,
b.username,
b.osuser,
b.paddr,
b.process,
b.logon_time,
b.type,
a.event,
a.total_waits,
a.total_timeouts,
a.time_waited,
a.average_wait,
a.max_wait,
sysdate as logoff_timestamp
from v$session_event a, v$session b
where 1 = 2;
-------------------------------
--
--Create table
-- SESSTAT_HISTORY
--
-------------------------------
create table sesstat_history
as
select c.username,
c.osuser,
a.sid,
c.serial#,
c.paddr,
c.process,
c.logon_time,
a.statistic#,
b.name,
a.value,
sysdate as logoff_timestamp
from v$sesstat a, v$statname b, v$session c
where 1 = 2;
--建立 DB logoff trigger
------------------------------
--
-- Create Trigger
--
------------------------------
-- This script creates a database logoff trigger for the purpose of
-- collecting historical performance data during logoffs.
-- It is applicable to Oracle8i Database and above.
-- You must be connected as “/ as sysdba” to create this trigger.
create or replace trigger logoff_trig
before logoff on database
declare
logoff_sid pls_integer;
logoff_time date := sysdate;
begin
select sid
into logoff_sid
from v$mystat
where rownum < 2;
insert into session_event_history
(sid, serial#, username, osuser, paddr, process,
logon_time, type, event, total_waits, total_timeouts,
time_waited, average_wait, max_wait, logoff_timestamp)
select a.sid, b.serial#, b.username, b.osuser, b.paddr, b.process,
b.logon_time, b.type, a.event, a.total_waits, a.total_timeouts,
a.time_waited, a.average_wait, a.max_wait, logoff_time
from v$session_event a, v$session b
where a.sid = b.sid
and b.username = login_user
and b.sid = logoff_sid;
-- If you are on earlier releases of Oracle9i Database, you should check to
-- see if your database is affected by bug #2429929, which causes
-- misalignment of SID numbers between the V$SESSION_EVENT and V$SESSION
-- views. The SID number in the V$SESSION_EVENT view is off by 1.
-- If your database is affected, please replace the above
-- “where a.sid = b.sid” with “where b.sid = a.sid + 1”.
insert into sesstat_history
(username, osuser, sid, serial#, paddr, process, logon_time,
statistic#, name, value, logoff_timestamp)
select c.username, c.osuser, a.sid, c.serial#, c.paddr, c.process,
c.logon_time, a.statistic#, b.name, a.value, logoff_time
from v$sesstat a, v$statname b, v$session c
where a.statistic# = b.statistic#
and a.sid = c.sid
and b.name in ('CPU used when call started',
'CPU used by this session',
'recursive cpu usage',
'parse time cpu')
and c.sid = logoff_sid
and c.username = login_user;
end;
/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/207/viewspace-812826/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 用 logoff trigger 保留每個 session 的效能資訊GoSession
- 用 logoff trigger 保留每個 session 的效能資訊(轉)GoSession
- OWI --用 stored procedure 收集session wait 資訊SessionAI
- Database Logoff Trigger SQLDatabaseGoSQL
- servlet中如何保留session???ServletSession
- postman trigger xdebug session in phpstormPostmanSessionPHPORM
- 9i -- 確認每個連線使用者session佔用的記憶體量Session記憶體
- owI 事件的收集事件
- oracle實用sql(5)--session相關資訊OracleSQLSession
- 使用logon trigger完成動態的session跟蹤GoSession
- OWI效能診斷與調整實踐指南(1~4)
- Oracle效能優化方法論的發展之二:基於OWI的效能優化方法論Oracle優化
- 【Oracle九大效能檢視】之4.v$sesstat_根據session id查session的統計資訊OracleSession
- 讀書筆記-高階owi與oracle效能調整-io筆記Oracle
- 讀書筆記-高階owi與oracle效能調整-segment筆記Oracle
- 讀書筆記-高階owi與oracle效能調整-transaction筆記Oracle
- 和某個session關聯的程式和使用者資訊Session
- Oracle效能最佳化方法論的發展之二:基於OWI的效能最佳化方法論Oracle
- 保留最近的2個歸檔
- logon on database記錄登入資訊的triggerGoDatabase
- ORACLE OWI介紹Oracle
- 讀書筆記-高階owi與oracle效能調整-network筆記Oracle
- 讀書筆記-高階owi與oracle效能調整-share pool筆記Oracle
- 讀書筆記-高階owi與oracle效能調整-cache buffer筆記Oracle
- 讀書筆記-高階owi與oracle效能調整-oracle internal筆記Oracle
- pytest+allure 生成測試報告,如果保留同一個測試用例的多次執行的日誌資訊。測試報告
- 用Java獲得當前效能資訊Java
- OWI的等待事件的簡單收集事件
- 讀書筆記-高階owi與oracle效能調整-latch和lock筆記Oracle
- 查詢資料庫每個表佔用的大小資料庫
- 關於檔案頭保留塊資訊的儲存探索
- Flurry:資訊類應用月保留率達到68% 是平均值的近2倍
- mysql備份每個庫下面每個表MySql
- 如何查詢以往的session歷史資訊Session
- 檢視鎖定的session資訊指令碼Session指令碼
- Oracle 動態效能表 v$session & v$process各個欄位的說明OracleSession
- Python實用技法第2篇:使用deque保留最新的N個元素Python
- 直接拿去用!每個App都會用到的LoadingLayoutAPP