Oracle效能調整的要點之SGA

來源:互聯網
上載者:User

一、Shared pool tunning

Shared pool的最佳化應該放在優先考慮,因為一個cache miss在shared pool中發生比在data buffer中 發生導致的成本更高,由於dictionary資料一般比library cache中的資料在記憶體中儲存的時間長,所以 關鍵是library cache的最佳化。

Gets:(parse)在namespace中尋找對象的次數;

Pins:(execution)在namespace中讀取或執行對象的次數;

Reloads:(reparse)在執行階段library cache misses的次數,導致sql需要重新解析。

1. 檢查v$librarycache中sql area的gethitratio是否超過90%,如果未超過90%,應該檢查應用代 碼,提高應用代碼的效率。

Select gethitratio from v$librarycache where namespace=’sql area’;

2. v$librarycache中reloads/pins的比率應該小於1%,如果大於1%,應該增加參數 shared_pool_size的值。

Select sum(pins) “executions”,sum(reloads) “cache misses”,sum(reloads)/sum(pins) from v$librarycache;

reloads/pins>1%有兩種可能,一種是library cache空間不足,一種是sql中引用的對象不合法。

3. shared pool reserved size一般是shared pool size的10%,不能超過50%。 V$shared_pool_reserved中的request misses=0或沒有持續增長,或者free_memory大於shared pool reserved size的50%,表明shared pool reserved size過大,可以壓縮。

4. 將大的匿名pl/sql代碼塊轉換成小的匿名pl/sql代碼塊調用儲存過程。

5.從9i開始,可以將execution plan與sql語句一起儲存在library cache中,方便進行效能診斷。從 v$sql_plan中可以看到execution plans。

6. 保留大的對象在shared pool中。大的對象是造成記憶體片段的主要原因,為了騰出空間許多小對象 需要移出記憶體,從而影響了使用者的效能。因此需要將一些常用的大的對象保留在shared pool中,下列對 象需要保留在shared pool中:

a. 經常使用的儲存過程;

b. 經常操作的表上的已編譯的觸發器

c. Sequence,因為Sequence移出shared pool後可能產生號碼丟失。

尋找沒有儲存在library cache中的大對象:

Select * from v$db_object_cache where sharable_mem>10000 and type in (’ PACKAGE’,'PROCEDURE’,'FUNCTION’,'PACKAGE BODY’) and kept=’NO’;

將這些對象儲存在library cache中:

Execute dbms_shared_pool.keep(‘package_name’);

對應指令碼:dbmspool.sql

7. 尋找是否存在過大的匿名pl/sql代碼塊。兩種解決方案:

a. 轉換成小的匿名塊調用預存程序

b. 將其保留在shared pool中

尋找是否存在過大的匿名pl/sql塊:

Select sql_text from v$sqlarea where command_type=47 and length(sql_text)>500;

8. Dictionary cache的最佳化

避免出現Dictionary cache的misses,或者misses的數量保持穩定,只能通過調整shared_pool_size來 間接調整dictionary cache的大小。

Percent misses應該很低:大部分應該低於2%,合計應該低於15%

Select sum(getmisses)/sum(gets) from v$rowcache;

若超過15%,增加shared_pool_size的值。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.