Oracle查询dbtime,以及各个指标的查询脚本
admin
2023-02-07 03:20:04
0

set linesize 1000
set pagesize 1000
col snap_date for a10
col "TIME" for a6
col "elapse(min)" for a6
col redo for 9999999999
col "DB time(min)" for 99999.99
select s.snap_date,
decode(s.redosize, null, '--shutdown or end--', s.currtime) "TIME",
to_char(round(s.seconds/60,2)) "elapse(min)",
round(t.db_time / 1000000 / 60, 2) "DB time(min)",
s.redosize redo,
round(s.redosize / s.seconds, 2) "redo/s",
s.logicalreads logical,
round(s.logicalreads / s.seconds, 2) "logical/s",
physicalreads physical,
round(s.physicalreads / s.seconds, 2) "phy/s",
s.executes execs,
round(s.executes / s.seconds, 2) "execs/s",
s.parse,
round(s.parse / s.seconds, 2) "parse/s",
s.hardparse,
round(s.hardparse / s.seconds, 2) "hardparse/s",
s.transactions trans,
round(s.transactions / s.seconds, 2) "trans/s"
from (select curr_redo - last_redo redosize,
curr_logicalreads - last_logicalreads logicalreads,
curr_physicalreads - last_physicalreads physicalreads,
curr_executes - last_executes executes,
curr_parse - last_parse parse,
curr_hardparse - last_hardparse hardparse,
curr_transactions - last_transactions transactions,
round(((currtime + 0) - (lasttime + 0)) 3600 24, 0) seconds,
to_char(currtime, 'yy/mm/dd') snap_date,
to_char(currtime, 'hh34:mi') currtime,
currsnap_id endsnap_id,
to_char(startup_time, 'yyyy-mm-dd hh34:mi:ss') startup_time
from (select a.redo last_redo,
a.logicalreads last_logicalreads,
a.physicalreads last_physicalreads,
a.executes last_executes,
a.parse last_parse,
a.hardparse last_hardparse,
a.transactions last_transactions,
lead(a.redo, 1, null) over(partition by b.startup_time order by b.end_interval_time) curr_redo,
lead(a.logicalreads, 1, null) over(partition by b.startup_time order by b.end_interval_time) curr_logicalreads,
lead(a.physicalreads, 1, null) over(partition by b.startup_time order by b.end_interval_time) curr_physicalreads,
lead(a.executes, 1, null) over(partition by b.startup_time order by b.end_interval_time) curr_executes,
lead(a.parse, 1, null) over(partition by b.startup_time order by b.end_interval_time) curr_parse,
lead(a.hardparse, 1, null) over(partition by b.startup_time order by b.end_interval_time) curr_hardparse,
lead(a.transactions, 1, null) over(partition by b.startup_time order by b.end_interval_time) curr_transactions,
b.end_interval_time lasttime,
lead(b.end_interval_time, 1, null) over(partition by b.startup_time order by b.end_interval_time) currtime,
lead(b.snap_id, 1, null) over(partition by b.startup_time order by b.end_interval_time) currsnap_id,
b.startup_time
from (select snap_id,
dbid,
instance_number,
sum(decode(stat_name, 'redo size', value, 0)) redo,
sum(decode(stat_name,
'session logical reads',
value,
0)) logicalreads,
sum(decode(stat_name,
'physical reads',
value,
0)) physicalreads,
sum(decode(stat_name, 'execute count', value, 0)) executes,
sum(decode(stat_name,
'parse count (total)',
value,
0)) parse,
sum(decode(stat_name,
'parse count (hard)',
value,
0)) hardparse,
sum(decode(stat_name,
'user rollbacks',
value,
'user commits',
value,
0)) transactions
from dba_hist_sysstat
where stat_name in
('redo size',
'session logical reads',
'physical reads',
'execute count',
'user rollbacks',
'user commits',
'parse count (hard)',
'parse count (total)')
group by snap_id, dbid, instance_number) a,
dba_hist_snapshot b
where a.snap_id = b.snap_id
and trunc(b.begin_interval_time)>=sysdate-7
and a.instance_number=(select instance_number from v$instance)
and a.dbid = b.dbid
and a.instance_number = b.instance_number
and a.dbid=(select dbid from v$database)
order by end_interval_time)) s,
(select lead(a.value, 1, null) over(partition by b.startup_time order by b.end_interval_time) - a.value db_time,
lead(b.snap_id, 1, null) over(partition by b.startup_time order by b.end_interval_time) endsnap_id
from dba_hist_sys_time_model a, dba_hist_snapshot b
where a.snap_id = b.snap_id
and trunc(b.begin_interval_time)>=sysdate-7
and a.dbid = b.dbid
and a.instance_number = b.instance_number
and a.instance_number=(select instance_number from v$instance)
and a.stat_name = 'DB time'
and a.dbid=(select dbid from v$database)) t
where s.endsnap_id = t.endsnap_id
order by s.snap_date,time ;

相关内容

热门资讯

“文学超界面”探索数字时代人文... 来源:新华网 当严肃文学的深厚内核遇见人工智能生成内容(AIGC)的影像创造力,会碰撞出怎样的火花...
以防长称已为应对伊朗局势做好“... △以色列国防部长卡茨(资料图)当地时间23日,据以色列方面消息,以色列国防部长卡茨当天表示,鉴于当前...
美参议院否决限制特朗普对伊战争... △美国国会(资料图)当地时间23日,美国参议院以49票对47票的表决结果,否决了旨在限制特朗普对伊朗...
工信部部长:搞“脱钩断链”对谁... 7月23日,2026年亚太经合组织(APEC)数字和人工智能部长会议新闻发布会在成都召开。会议主席、...
AMD展示最强AI加速器MI4... IT之家 7 月 24 日消息,今天(7 月 24 日)在美国旧金山召开的年度盛会 Advancin...
河北:知行研学度盛夏 多彩实践... 冀时新闻报道暑假期间,我省各地推出形式多样的青少年研学活动,让孩子们在实践中增长见识、锤炼品格,度过...
世界互联网大会数智健康工作组以... 7月22日,2026年世界互联网大会数字丝路发展论坛在陕西西安开幕。这是世界互联网大会连续第三年举办...
开立医疗获得实用新型专利授权:... 证券之星消息,根据天眼查APP数据显示开立医疗(300633)新获得一项实用新型专利授权,专利名为“...
成都深入实施“人工智能+”行动 成都深入实施“人工智能+”行动 到2027年实现人工智能核心产业规模突破2600亿元 华西都市报讯(...
原创 中... 说真的,看到欧洲科学家一本正经拿粪水浇菜做研究,最后还得出了个“安全无害、肥力充足”的结论,我第一反...