v$active_session_history檢視[轉]
http://asmboy001.blog.51cto.com/340398/111240
指令碼摘自《教你如何成為oracle 10g OCP》
查詢最近一分鐘內,最消耗CPU的sql語句
select sql_id,count(*),
round(count(*)/sum(count(*)) over (),2) pctload
from v$active_session_history
where sample_time > sysdate -1/(24*60)
and session_type <> 'BACKGROUND'
and session_state= 'ON CPU'
group by sql_id
order by count(*) desc;
查詢最近一分鐘內,最消耗I/O的sql語句
select ash.sql_id,count(*)
from v$active_session_history ash,v$event_name evt
where ash.sample_time > sysdate -1/(24*60)
and ash.session_state = 'WAITING'
and ash.event_id = evt.event_id
and evt.wait_class = 'USER I/O'
group by ash.sql_id
order by count(*) desc;
查詢最近一分鐘內,最消耗CPU的session
select session_id,count(*)
from v$active_session_history
where session_state = 'ON CPU'
and sample_time > sysdate -1/(24*60)
group by session_id
order by count(*) desc;
查詢最近一分鐘內,最消耗資源的sql語句
select ash.sql_id,
sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
sum(decode(ash.session_state,'WAITING',1,0)) -
sum(decode(ash.session_state,'WAITING',decode(en.wait_class,'USER I/O',1,0),0)) "WAIT",
sum(decode(ash.session_state,'WAITING',decode(en.wait_class,'USER I/O',1,0),0))
"IO",
sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"
from v$active_session_history ash,v$event_name en
where SQL_ID is not null and en.event#=ash.event# and ash.sample_time > sysdate -1/(24*60)
group by ash.sql_id
order by sum(decode(ash.session_state,'ON CPU',1,1)) desc;
查詢最近一分鐘內,最消耗資源的session
select ash.session_id,ash.session_serial#,ash.user_id,ash.program,
sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
sum(decode(ash.session_state,'WAITING',1,0)) -
sum(decode(ash.session_state,'WAITING',decode(en.wait_class,'USER I/O',1,0),0)) "WAITING",
sum(decode(ash.session_state,'WAITING',decode(en.wait_class,'USER I/O',1,0),0))
"IO",
sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"
from v$active_session_history ash,v$event_name en
where en.event# = ash.event# and ash.sample_time > sysdate -1/(24*60)
group by ash.session_id,ash.user_id,ash.session_serial#,ash.program
order by sum(decode(ash.session_state,'ON CPU',1,1))
select sql_id,count(*),
round(count(*)/sum(count(*)) over (),2) pctload
from v$active_session_history
where sample_time > sysdate -1/(24*60)
and session_type <> 'BACKGROUND'
and session_state= 'ON CPU'
group by sql_id
order by count(*) desc;
查詢最近一分鐘內,最消耗I/O的sql語句
select ash.sql_id,count(*)
from v$active_session_history ash,v$event_name evt
where ash.sample_time > sysdate -1/(24*60)
and ash.session_state = 'WAITING'
and ash.event_id = evt.event_id
and evt.wait_class = 'USER I/O'
group by ash.sql_id
order by count(*) desc;
查詢最近一分鐘內,最消耗CPU的session
select session_id,count(*)
from v$active_session_history
where session_state = 'ON CPU'
and sample_time > sysdate -1/(24*60)
group by session_id
order by count(*) desc;
查詢最近一分鐘內,最消耗資源的sql語句
select ash.sql_id,
sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
sum(decode(ash.session_state,'WAITING',1,0)) -
sum(decode(ash.session_state,'WAITING',decode(en.wait_class,'USER I/O',1,0),0)) "WAIT",
sum(decode(ash.session_state,'WAITING',decode(en.wait_class,'USER I/O',1,0),0))
"IO",
sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"
from v$active_session_history ash,v$event_name en
where SQL_ID is not null and en.event#=ash.event# and ash.sample_time > sysdate -1/(24*60)
group by ash.sql_id
order by sum(decode(ash.session_state,'ON CPU',1,1)) desc;
查詢最近一分鐘內,最消耗資源的session
select ash.session_id,ash.session_serial#,ash.user_id,ash.program,
sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
sum(decode(ash.session_state,'WAITING',1,0)) -
sum(decode(ash.session_state,'WAITING',decode(en.wait_class,'USER I/O',1,0),0)) "WAITING",
sum(decode(ash.session_state,'WAITING',decode(en.wait_class,'USER I/O',1,0),0))
"IO",
sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"
from v$active_session_history ash,v$event_name en
where en.event# = ash.event# and ash.sample_time > sysdate -1/(24*60)
group by ash.session_id,ash.user_id,ash.session_serial#,ash.program
order by sum(decode(ash.session_state,'ON CPU',1,1))
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24570973/viewspace-753012/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- V$ACTIVE_SESSION_HISTORY檢視的使用Session
- [20211214]檢視檢視V$ACTIVE_SESSION_HISTORY遇到奇怪問題.txtSession
- 檢視V$DATAGUARD_STATS
- 將檢視轉為表
- [20211019]V$DETACHED_SESSION檢視.txtSession
- [20210528]V$INDEXED_FIXED_COLUMN檢視.txtIndex
- [20210418]查詢v$檢視問題.txt
- [轉載]SQLServer之檢視簡介SQLServer
- [20181103]12c檢視V$EVENT_NAME.txt
- ORACLE 閃回檢視v$flashback_database_log/statOracleDatabase
- [20201207]12c v$open_cursor檢視.txt
- [轉帖]Windows netstat 檢視埠、程序佔用Windows
- 如何檢視heic heic格式怎麼轉換
- Linux 檢視設定系統語言(轉)Linux
- v$parameter gv$parameter 檢視 DDL 與隱含引數
- Java物件導向系列[v1.0.0][索引與檢視]Java物件索引
- 11 UML中的邏輯檢視、程序檢視、實現檢視、部署檢視
- [Django REST framework - 檢視元件之檢視基類、檢視擴充套件類、檢視子類、檢視集]DjangoRESTFramework元件套件
- 【轉】改變檢視頁面原始碼的程式原始碼
- 轉:Linux檢視GPU資訊和使用情況LinuxGPU
- 檢視mysql 的binlog日誌存放的位置(轉)MySql
- 【SQL】Oracle查詢轉換之檢視合併SQLOracle
- 透過v$sql_bind_capture 檢視繫結變數。SQLAPT變數
- Metadata for Mac(影像後設資料檢視器)v1.7Mac
- ASP.NET Core 5.0 MVC中的檢視分類——佈局檢視、啟動檢視、具體檢視、分部檢視ASP.NETMVC
- [20190312]檢視v$datafile欄位OFFLINE_CHANGE#, ONLINE_CHANGE#.txt
- 快速影像檢視器:EdgeView 4 for Mac v4.4.2啟用版ViewMac
- 快速影像檢視器:EdgeView 4 for Mac v4.4.5啟用版ViewMac
- EdgeView 2 for Mac(影像檢視軟體) v2.917啟用版ViewMac
- (轉載)iOS中獲取某個檢視的截圖iOS
- heic安卓上如何檢視,怎麼轉換heic格式安卓
- heic檔案電腦如何檢視,怎麼轉換heic
- 【手摸手玩轉 OceanBase 159】如何檢視歸檔引數?
- 【手摸手玩轉 OceanBase 177】如何檢視恢復進度?
- 前端技術分享:教你玩轉vue-router命令檢視前端Vue
- [20180907]訪問v$檢視與一致性讀取.txt
- 怎樣清除v$archived_log檢視中的過期資訊Hive
- 輕量級影像檢視器:Lyn for Mac v2.3.6漢化版Mac
- [20200211]檢視v$db_object_cache的CHILD_LATCH欄位.txtObject