zoukankan      html  css  js  c++  java
  • latch相关视图整理

    latch相关视图整理(原创)
    V$LATCH
    V$LATCH视图在选取X$KSLLT记录时,进行了Group By及SUM运算,从而得出了一个汇总信息,保存了自实例启动后各类栓锁的统计信息。常用于当v$session_wait中发现栓锁竞争时鉴别SGA区中问题所在区域。
     
    v$latch表的每一行包括了对不同类型latch的统计,每一列反映了不同类型的latch请求的活动情况。不同类型的latch请求之间的区别在于,当latch不可立即获得时,请求进程是否继续进行。按此分类,latch请求的类型可分为两类:willing-to-wait和immediate。
     
    Willing-to-wait:是指如果所请求的latch不能立即得到,请求进程将等待一很短的时间后再次发出请求。进程一直重复此过程直到得到latch。 
     
    Immediate:是指如果所请求的latch不能立即得到,请求进程就不再等待,而是继续执行下去。
     
    V$LATCH中的常用列:
    NAME:latch名称
    IMMEDIATE_GETS:以Immediate模式latch请求数
    IMMEDIATE_MISSES:IMMEDIATE_GETS的失败数
    GETS:以Willing to wait请求模式latch的请求数
    MISSES:GETS that did not obtain the latch on first try,Gets 不成功次数
    SPIN_GETS:GETS that got the latch within SPIN_GET tries and did not have to sleep 第一次尝试失败,但在以后的轮次中成功
    SLEEP1-SLEEP3: GETS that succeeded only after sleeping one to three times
    SLEEP4: GETS that only succeeded after sleeping four or more times
    WAIT_TIME: Elapsed time spent waiting for this latch ,花费在等待latch的时间
    MISSES_WAITLIST: Number of latch misses on the associated wait list latch 
    SLEEPS_WAITLIST: Number of sleeps while trying to acquire the associated wait list latch 
    WAIT_TIME_WAITLIST: Wait time for the associated wait list latch
     
    关于latch的统计信息,主要关注以下几部分
     
    misses/gets的比率是多少
    获自spinning的misses的百分比是多少
    latch请求了多少次
    latch休眠了多少次
     
    latch有40余种,但作为DBA关心的主要应有以下几种: 
    Cache buffers chains latch:当用户进程搜索SGA寻找database cache buffers时需要使用此latch。
    Cache buffers LRU chain latch:当用户进程要搜索buffer cache中包括所有 dirty blocks的LRU (least recently used) 链时使用该种latch。 
    Redo log buffer latch:这种latch控制redo log buffer中每条redo entries的空间分配。 
    Row cache objects latch:当用户进程访问缓存的数据字典数值时,将使用Row cache objects
    latch。
     
    V$LATCH_CHILDREN
    V$LATCH_CHILDREN是具体每个子LATCH的统计,V$LATCH是每一种LATCH的统计,前者比后者多了一个CHILD#,相同的LATCH#表示同种LATCH,ADDR是子LATCH的地址。V$LATCH_CHILDREN视图和v$Latch视图的差别与v$sql和v$sqlarea的区别相似并不进行汇总运算,所以也就显示了子Latch的相关信息。所谓子Latch就是library cache在系统中包含了多少个具体的物理数量的library
    cache,他们的分配原则是这样的。v$latch_children内容的条数一般都是v$latch
    cpu+1倍,例如:从v$latch查询出有1个library cache latches,系统cpu个数为2,则v$latch_children中library cache latches的子latch个数应该为3。
    v$latch_children除了比v$latch多了child#其他列都一样,这里不再赘述。

    V$LATCHHOLDER 
    通过v$latchholder可以查看当前持有latch的会话和进程。由于LATCH的等待时间都很短,该视图多用于查看长时间等待LATCH的SESSION
    PID:进程标识,用于和v$process关联
    SID: 会话标识,用于和V$SESSION关联
    LADDR: Latch address  V$LATCH_CHILDRN    
    NAME: Name of the latch being held V$LATCH / V$LATCHNAME / V$LATCH_CHILDRN
    GETS:NUMBER Number of times that the latch was obtained in either wait mode or no-wait mode
     
    V$LATCHNAME
    显示了v$latch中latch的名称,和v$latch中的信息一一对应
    LATCH#:Latch number
    NAME:Latch name
    HASH:Latch hash
     
    常用SQL 

    #查看持有latch的sql信息和会话信息
    SELECT s.sql_hash_value,s.sql_id,s.sid l.name
      FROM V$SESSION s, V$LATCHHOLDER l
    WHERE s.sid = l.sid;
     
    #根据latch名称显示对latch的统计信息
    select c.name,a.addr,a.gets,a.misses,a.sleeps,
    a.immediate_gets,a.immediate_misses,b.pid
    from v$latch a, v$latchholder b, v$latchname c
    where a.addr = b.laddr(+) and a.latch# = c.latch#
    and c.name like '&latch_name%' order by a.latch#;
     
    # 查看latch的命中率
    SQL>SELECT name, gets, misses, sleeps, 
          immediate_gets, immediate_misses
         FROM v$latch
       WHERE name = 'cache buffers chains';
     
    # 如果在Top 5中发现latch free热点块事件时,可以从V$latch_children中查询具体的子Latch信息
    SELECT *
      FROM (SELECT   addr, child#, gets, misses, sleeps, immediate_gets igets,
                    immediate_misses imiss, spin_gets sgets
                FROM v$latch_children
               WHERE NAME = 'cache buffers chains'
            ORDER BY sleeps DESC)
     WHERE ROWNUM < 11;
  • 相关阅读:
    fzuoj Problem 2177 ytaaa
    zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
    zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
    zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
    zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
    zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak
    zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
    zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients
    zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces
    csuoj 1335: 高桥和低桥
  • 原文地址:https://www.cnblogs.com/jackhub/p/3349736.html
Copyright © 2011-2022 走看看