gdufo

           

          什么是LATCH ? 什么又導致LATCH 競爭?

          轉:
          http://carson.ycool.com/post.1264755.html

          • oracle 采用 latch、enqueue、distribute lock 、global lock等來進行‘鎖’的管理
          • Latches are low level serialization mechanisms used to protect shared data structures in the SGA. A latch is a type  of a lock that can be very quickly acquired and freed
          • Enqueue 是另外一種鎖,An enqueue is a more sophisticated mechanism which permits several concurrent processes to have varying degree of sharing of "known" resources. Any object which can be concurrently used, can be protected with enqueues. 它于 latch的不同之處在于,它是OS級別的,由OS的lock manger 來進行管理,并且嚴格遵守FIFO,而latch 確不然,很有可能是先申請latch的進程,卻最后得到latch
          • A process acquires a latch when working with a structure in the SGA (System Global Area).  在process 工作的過程中持有,在工作結束的時候釋放,在process 意外結束的時候,由PMON 來收拾殘局
          • Latch 有兩種,一個是willing-to-wait,一個是no wait
          • 如果一個process 申請latch 沒有申請的到,就開始spin,spin的次數有_spin_count參數來決定,當達到_spin_count的值時,就開始休眠,休眠時間為0.01秒
          • 主要相關視圖:v$latch,v$latch_misses,v$latch_name,

          主要的Latch

          • Cache buffers chains latch:    產生:在data buffer 有block 被access的時候產生; 解決: 減少這個latch 競爭就是要減少sql 的邏輯IO
          • Cache buffers LRU chain latch:  產生: 1、當一個新的block 被讀到data buffer 的時候 2、data 從databuffer 寫到disk   3、對Data buffer 進行scan 以獲得那些block是dirty 時候;   解決: 1、加大data buffer,但是這對于FTS 比較多的系統并不中用  2、設置Multiple buffer pools   3、加大DB_BLOCK_LRU_LATCHES 參數的值  4、always ensure DB_BLOCK_LRU_STATISTICS is set to FALSE
          • Redo allocation latch:   產生:在log buffer中分配空間的時候獲得,一個instance 只有一個Redo allocation latch ; 解決:1、加大log buffer    2、設置 nologging 選項
          • Redo copy latch:   產生:當系統將redo records 寫到log buffer 的時候產生; 
          • Library cache latch:   產生:The library cache latches 保護cached 的sql 語句,以及cached 的object 的定義,它是當將新的解析的sql 語句 插入到library cache 的時候產生,該值過大,表示hard parse 過多;  解決: 1、綁定變量   2、 適當加大shared pool     3、加大_KGL_LATCH_COUNT 參數
          • Library cache pin latch:  產生: 當cached sql 語句再次被執行的時候產生,這個latch 的嚴重丟失表明sql 被嚴重的多次執行;   解決: 幾乎沒有辦法來解決該問題,一個效果不大的辦法是書寫:a.b 類似的sql
          • Shared pool latch:   the shared pool latchis used to protect critical operations when allocating and freeing memory in the shared pool.     解決:  1、綁定變量   2、避免hard parse   3、盡量一次解析多次執行   4、適當的shared_pool  5、MTS
          • Row cache objects latch:    產生: 當用戶進程讀取數據字典定義的時候      解決: 加大shared_pool

          如果一個系統中的CPU 很繁忙,就應該減少_SPIN_COUNT 的值,反之,就應該增加

          posted on 2009-12-09 10:47 gdufo 閱讀(800) 評論(0)  編輯  收藏 所屬分類: Database (oracle, sqlser,MYSQL)

          導航

          統計

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          Hibernate

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 清新县| 固镇县| 静乐县| 桓仁| 大埔县| 杭州市| 财经| 宿州市| 洞口县| 关岭| 砚山县| 汉寿县| 宝丰县| 武鸣县| 鹤壁市| 泰安市| 桃园市| 奉节县| 建湖县| 塔河县| 安图县| 鲜城| 台前县| 湟源县| 讷河市| 万载县| 峨眉山市| 瓦房店市| 静宁县| 滦平县| 阳原县| 淄博市| 神木县| 武安市| 民勤县| 湘潭市| 新平| 察哈| 兴隆县| 康保县| 泰和县|