本篇內(nèi)容主要講解“Oracle常用性能分析語(yǔ)句有哪些”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“Oracle常用性能分析語(yǔ)句有哪些”吧!
專注于為中小企業(yè)提供成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)陳巴爾虎免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了數(shù)千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。1、查看數(shù)據(jù)庫(kù)中過去15分鐘內(nèi)排在前5位的等待事件及其總等待時(shí)間
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分鐘內(nèi)使用CPU及資源最多的前5位會(huì)話
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列有兩個(gè)有效的值:ON CPU和WAITING,分別表示會(huì)話是活動(dòng)的還是在等待資源,同樣將session_state指定為WAITING值,可以查看在等待資源的前5位會(huì)話信息。
3、查看那些業(yè)務(wù)用戶占用最多的資源
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、定位造成大量資源消耗的對(duì)象信息
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分鐘內(nèi)造成最多數(shù)據(jù)庫(kù)等待的sql語(yǔ)句
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、找出誰(shuí)持有阻塞鎖
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 ;
到此,相信大家對(duì)“Oracle常用性能分析語(yǔ)句有哪些”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!