日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle 等待原因查找,oracle等待事件相关查询

發(fā)布時間:2024/7/23 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle 等待原因查找,oracle等待事件相关查询 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

--------------------------查詢數(shù)據(jù)庫等待時間和實際執(zhí)行時間的相對百分比---------------------

select *

from v$sysmetric a

where a.METRIC_NAME in

('Database CPU Time Ratio', 'Database Wait Time Ratio')

and a.INTSIZE_CSEC = (select max(intsize_csec) from v$sysmetric);

-------------------------------------查詢數(shù)據(jù)庫中過去30分鐘引起最多等待的sql語句----------------

select ash.USER_ID,

u.username,

sum(ash.WAIT_TIME) ttl_wait_time,

s.SQL_TEXT

from v$active_session_history ash, v$sqlarea s, dba_users u

where ash.SAMPLE_TIME between sysdate - 60 / 2880 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 desc

-----------------------------------------查詢數(shù)據(jù)庫中的等待事件----------------------

select event, count()

from v$session_wait

group by event

order by count() desc

---------------------------------------查詢數(shù)據(jù)庫過去15分鐘最重要的等待事件---------------

select ash.EVENT, sum(ash.WAIT_TIME + ash.TIME_WAITED) total_wait_time

from v$active_session_history ash

where ash.SAMPLE_TIME between sysdate - 30 / 2880 and sysdate

group by event

order by total_wait_time desc

----------------------------------------在過去15分鐘哪些用戶經(jīng)歷了等待---------------------

select s.SID,

s.USERNAME,

sum(ash.WAIT_TIME + ash.TIME_WAITED) total_wait_time

from v$active_session_history ash, v$session s

where ash.SAMPLE_TIME between sysdate - 30 / 2880 and sysdate

and ash.SESSION_ID = s.SID

group by s.SID, s.USERNAME

order by total_wait_time desc;

-------------------------------------查詢等待時間最長的對象---------------------------------------

select a.CURRENT_OBJ#,

d.object_name,

d.object_type,

a.EVENT,

sum(a.WAIT_TIME + a.TIME_WAITED) total_wait_time

from v$active_session_history a, dba_objects d

where a.SAMPLE_TIME between sysdate - 30 / 2880 and sysdate

and a.CURRENT_OBJ# = d.object_id

group by a.CURRENT_OBJ#, d.object_name, d.object_type, a.EVENT

order by total_wait_time desc;

--------------------------------------------查詢過去15分鐘等待時間最長的sql語句---------------------------

select a.USER_ID,

u.username,

s.SQL_TEXT,

sum(a.WAIT_TIME + a.TIME_WAITED) total_wait_time

from v$active_session_history a, v$sqlarea s, dba_users u

where a.SAMPLE_TIME between sysdate - 30 / 2880 and sysdate

and a.SQL_ID = s.SQL_ID

and a.USER_ID = u.user_id

group by a.USER_ID, s.SQL_TEXT, u.username

order by total_wait_time desc;

------------------------------------------那些SQL消耗更多的IO--------------------------------------

select *

from (select s.PARSING_SCHEMA_NAME,

s.DIRECT_WRITES,

substr(s.SQL_TEXT, 1, 500),

s.DISK_READS

from v$sql s

order by s.DISK_READS desc)

where rownum < 20

---------------------------------------查看哪些會話正在等待IO資源-------------------------------------

SELECT username, program, machine, sql_id

FROM V$SESSION

WHERE EVENT LIKE 'db file%read';

----------------------------------查看正在等待IO資源的對象-----------------------------------

SELECT d.object_name, d.object_type, d.owner

FROM V$SESSION s, dba_objects d

WHERE EVENT LIKE 'db file%read'

and s.ROW_WAIT_OBJ# = d.object_id

---------------------------查看redo日志切換頻率---------------------------------------------

Select round(FIRST_TIME, 'DD'), THREAD#, Count(SEQUENCE#)

From v$log_history

Group By round(FIRST_TIME, 'DD'), THREAD#

Order By 1, 2

SELECT ?trunc(first_time) "Date",

to_char(first_time, 'Dy') "Day",

count(1) "Total",

SUM(decode(to_char(first_time, 'hh24'),'00',1,0)) "h0",

SUM(decode(to_char(first_time, 'hh24'),'01',1,0)) "h1",

SUM(decode(to_char(first_time, 'hh24'),'02',1,0)) "h2",

SUM(decode(to_char(first_time, 'hh24'),'03',1,0)) "h3",

SUM(decode(to_char(first_time, 'hh24'),'04',1,0)) "h4",

SUM(decode(to_char(first_time, 'hh24'),'05',1,0)) "h5",

SUM(decode(to_char(first_time, 'hh24'),'06',1,0)) "h6",

SUM(decode(to_char(first_time, 'hh24'),'07',1,0)) "h7",

SUM(decode(to_char(first_time, 'hh24'),'08',1,0)) "h8",

SUM(decode(to_char(first_time, 'hh24'),'09',1,0)) "h9",

SUM(decode(to_char(first_time, 'hh24'),'10',1,0)) "h10",

SUM(decode(to_char(first_time, 'hh24'),'11',1,0)) "h11",

SUM(decode(to_char(first_time, 'hh24'),'12',1,0)) "h12",

SUM(decode(to_char(first_time, 'hh24'),'13',1,0)) "h13",

SUM(decode(to_char(first_time, 'hh24'),'14',1,0)) "h14",

SUM(decode(to_char(first_time, 'hh24'),'15',1,0)) "h15",

SUM(decode(to_char(first_time, 'hh24'),'16',1,0)) "h16",

SUM(decode(to_char(first_time, 'hh24'),'17',1,0)) "h17",

SUM(decode(to_char(first_time, 'hh24'),'18',1,0)) "h18",

SUM(decode(to_char(first_time, 'hh24'),'19',1,0)) "h19",

SUM(decode(to_char(first_time, 'hh24'),'20',1,0)) "h20",

SUM(decode(to_char(first_time, 'hh24'),'21',1,0)) "h21",

SUM(decode(to_char(first_time, 'hh24'),'22',1,0)) "h22",

SUM(decode(to_char(first_time, 'hh24'),'23',1,0)) "h23"

FROM ? ?V$log_history

group by trunc(first_time), to_char(first_time, 'Dy')

Order by 1

總結(jié)

以上是生活随笔為你收集整理的oracle 等待原因查找,oracle等待事件相关查询的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。