本篇內(nèi)容主要講解“Oracle常用性能分析語句有哪些”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“Oracle常用性能分析語句有哪些”吧!
創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站制作、成都做網(wǎng)站、外貿(mào)營銷網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)曲水,十年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792
1、查看數(shù)據(jù)庫中過去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ù)庫等待的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 ;
到此,相信大家對(duì)“Oracle常用性能分析語句有哪些”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
分享題目:Oracle常用性能分析語句有哪些
文章轉(zhuǎn)載:http://www.rwnh.cn/article18/jippgp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、商城網(wǎng)站、企業(yè)網(wǎng)站制作、建站公司、網(wǎng)站內(nèi)鏈、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)