您好,登錄后才能下訂單哦!
本篇內容主要講解“Oracle常用性能分析語句有哪些”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“Oracle常用性能分析語句有哪些”吧!
1、查看數據庫中過去15分鐘內排在前5位的等待事件及其總等待時間
select * from ( SELECT NVL(event, 'ON CPU') event, COUNT(*) total_wait_tm FROM v$active_session_history WHERE sample_time > SYSDATE - 15/(24*60) GROUP BY event ORDER BY 2 desc ) where rownum <= 5;
2、查看過去15分鐘內使用CPU及資源最多的前5位會話
column username format a12 column module format a30 SELECT * FROM ( SELECT s.username, s.module, s.sid, s.serial#, count(*) FROM v$active_session_history h, v$session s WHERE h.session_id = s.sid AND h.session_serial# = s.serial# AND session_state= 'ON CPU' AND sample_time > sysdate - interval '15' minute GROUP BY s.username, s.module, s.sid, s.serial# ORDER BY count(*) desc ) where rownum <= 5;
session_state列有兩個有效的值:ON CPU和WAITING,分別表示會話是活動的還是在等待資源,同樣將session_state指定為WAITING值,可以查看在等待資源的前5位會話信息。
3、查看那些業(yè)務用戶占用最多的資源
SELECT * FROM ( SELECT u.username, h.module, h.session_id sid, h.session_serial# serial#, count(*) FROM dba_hist_active_sess_history h, dba_users u WHERE h.user_id = u.user_id AND session_state= 'ON CPU' AND (sample_time between to_date('2018-07-22:00:00:00','yyyy-mm-dd:hh34:mi:ss') AND to_date('2018-07-22:23:59:59','yyyy-mm-dd:hh34:mi:ss')) AND u.username != 'SYS' GROUP BY u.username, h.module, h.session_id, h.session_serial# ORDER BY count(*) desc ) where rownum <= 5;
4、定位造成大量資源消耗的對象信息
SELECT * FROM ( select * from ( SELECT o.object_name, o.object_type, s.event, s.time_waited FROM dba_hist_active_sess_history s, dba_objects o WHERE s.sample_time between to_date('2018-07-22:00:00:00','yyyy-mm-dd:hh34:mi:ss') AND to_date('2018-07-22:23:59:59','yyyy-mm-dd:hh34:mi:ss') AND s.current_obj# = o.object_id ORDER BY 4 desc ) WHERE rownum <= 5;
5、查看過去15分鐘內造成最多數據庫等待的sql語句
select ash.user_id, u.username, s.sql_text, sum(ash.wait_time + ash.time_waited) ttl_wait_time from v$active_session_history ash, v$sqlarea s, dba_users u where ash.sample_time between sysdate - 15/(24*60) and sysdate and ash.sql_id = s.sql_id and ash.user_id = u.user_id group by ash.user_id,s.sql_text, u.username order by ttl_wait_time
6、找出誰持有阻塞鎖
select s1.username || '@' || s1.machine || ' ( SID=' || s1.sid || ' ) is blocking ' || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status from v$lock l1, v$session s1, v$lock l2, v$session s2 where s1.sid=l1.sid and s2.sid=l2.sid and l1.BLOCK=1 and l2.request > 0 and l1.id1 = l2.id1 and l2.id2 = l2.id2 ;
到此,相信大家對“Oracle常用性能分析語句有哪些”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續(xù)學習!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。