v$active_session_history的wait_time和time_waited 列

简介: 最近在弄informix,oracle调优也好久没碰了,今天朋友问我v$active_session_history的wait_time和time_waited 怎么看,只记得用过,一下也没想起。

最近在弄informix,oracle调优也好久没碰了,今天朋友问我v$active_session_history的wait_time和time_waited 怎么看,只记得用过,一下也没想起。连忙验证了下

wait_time 这列,对于在采样时,正在等待的事件,该列为0。对应session_state列。不为0的行是在进行CPU

time_waited这列,是这次等待的等待时间,如果该种类的等待的时间的超时时间大于1秒,那么如果等待了超过了1秒,本次采样的time_waited为0,在最后一次采样到该等待时,置上等待时间。单位百万分之一秒。也就是说,time_waited为0的行也不用看,因为等待时候在后面会体现,其和最后的行是同一次等待。

下面是以前用过的一个SQL

SELECT EVENT,
    COUNT(*) TOTAL_WAITS,
    TRUNC(SUM(TIME_WAITED) / 1000000) SECONDS_IN_WAIT
 FROM V$ACTIVE_SESSION_HISTORY
 WHERE SESSION_STATE = 'WAITING'
  AND TIME_WAITED > 0
  AND SAMPLE_ID BETWEEN 1800000 AND 2000000
  AND SESSION_ID = 144
  AND SQL_ID = 'cgb71p2hy4zfj'
 GROUP BY EVENT

其实v$active_session_history就是一个语句在运行中遇到的所有等待的统计,可以一定程度上代替10046来查看SQL遭遇的等待

相关文章
|
5月前
|
网络协议 Cloud Native
为什么需要 TIME_WAIT 状态
为什么需要 TIME_WAIT 状态
为什么需要 TIME_WAIT 状态
Sap Ds Data is not available. Increase the time-out interval values in Debug | Options
Sap Ds Data is not available. Increase the time-out interval values in Debug | Options
95 0
|
关系型数据库 MySQL
Mysql current_time,current_date()与now()区别
Mysql current_time,current_date()与now()区别
146 0
|
Shell
History displays the time information
For those of you who use terminals a lot, one of the most common commands is probably history, which allows you to view the history of terminal commands executed
96 0
|
SQL 关系型数据库 MySQL
Mysql数据库Slow_log中的lock_Time和Query_time
主要用简单的例子来说明,slow log里的lock_time和query_time的关系
Mysql数据库Slow_log中的lock_Time和Query_time
|
SQL 关系型数据库 MySQL
级联slave的延迟计算和query event exe time获取方法
一、级联时间计算方式 比如A->B->C那么C的延迟是计算B还是A的。因为Event的中timestamp没变,但是C计算时间差值却是以B为准。如果时钟同步的情况下,其实基本可以考虑为A的。计算方法可以参考我的《深入理解MySQL主从原理》专栏 逻辑如下: 级联中的Event依然是主库的时间,因此其延迟还是相对主库而言。
715 0
|
敏捷开发
Is It Time for Another IT Methodology Update?
Cloud computing starter packages can offer extraordinary value for money, but we need to Finance teams to work much more closely with IT teams.
2456 0
Is It Time for Another IT Methodology Update?
|
网络协议 测试技术 Go