oracle的dtime,Oracle查询dbtime,以及各个指标的查询脚本

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, ‘hh24:mi‘) currtime, currsnap_id endsnap_id, to_char(startup_time, ‘yyyy-mm-dd hh24: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 ;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]中的代码展示了如何使用Python中的datetimetime库来处理时间和日期。其中,dtime是一个datetime对象,表示特定的日期和时间。通过调用dtimetimetuple()方法,可以将其转换为时间元组。然后,可以使用time库的mktime()函数将时间元组转换为时间戳。另外,还可以使用fromtimestamp()函数将时间戳转换为日期和时间。 引用\[2\]中的代码展示了如何使用datetime库来处理日期。可以使用datetime.date.today()函数获取当前日期,也可以手动创建日期对象。通过访问日期对象的year、month和day属性,可以获取年、月和日的值。此外,还可以使用timedelta类来计算两个日期之间的天数差,或者向前或向后推移多少天。 根据提供的引用内容,无法确定变量dtime的具体含义和值。请提供更多上下文或具体问题,以便我能够更好地回答你的问题。 #### 引用[.reference_title] - *1* *2* [python 日期、时间、时间戳的转换,日期加减](https://blog.csdn.net/weixin_41558411/article/details/130786892)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [全网最全Python图算法](https://blog.csdn.net/qq_30759585/article/details/126454566)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值