轉 優化筆記oracle占用90

2021-06-01 19:23:51 字數 1194 閱讀 4815

優化筆記oracle占用90%

1. 當時知道的topas檢視的cpu 使用90%以上.

2. 檢視wait events

select a.event, b.sid , b.serial#,c.hash_value,c.sql_text

from v$session_wait a , v$session b , v$sqlarea c

where a.sid=b.sid

and b.sql_hash_value=c.hash_value

and a.event not like 'sql*net%'

and a.event not like 'rdbms%'

發現很多 db file scattered read  , 而這個表相對於是個字典表. 記錄數160萬左右.

sql大致語句: select * from tab where seg > :1 and seg < :2  , 而把sql 語句copy 到 pl/sql中 使用了index . 但是weit event 反而為scattered  read

懷疑執行計畫改變.

select st.sql_text from v$sqltext st where st.hash_value='&hash_value' order by piece

3 檢視系統使用的執行計畫.

select  sp.operation, sp.options, sp.object_owner, sp.object_name

from v$sql_plan sp

where sp.hash_value = '&hash_value'

這時發現執行計畫為full table scan , 可以判斷index 出了問題或者統計資訊不準確.

4. 了解業務可知這個表每天都需要同步資料, 有大量的insert , delete 操作.

alter index ind_name rebuild ; (當時也不能確定是否可用. 說原來發生過重建就好了. 估計是改變了執行計畫)

5. 重建完index 並沒有改變執行計畫.還是full table scan . 決定先刪除統計資訊. 因為這個表業務說只有這個地方使用.

analyze table tab delete statistics ;

之後檢視v$sql_plan 執行計畫改變 . index range scan .

Oracle優化筆記

2016 11 22 子查詢 標量子查詢 內聯檢視 in line view 半連線 反連線 標量子查詢 select 後跟子查詢 類似自定義函式 可用開窗函式之類的改寫 內聯檢視 in line view from 後跟子查詢 類似設計view 子查詢套子查詢是垃圾設計會帶來效能問題 半連線就是 ...

Oracle效能優化的學習筆記

記憶體優化 sga包括三個部分組成。資料緩衝區 日誌緩衝區及共享池 資料緩衝區 大小由db cache size引數決定。select name,value from v parameter where name in db cache size db block size shared pool ...

Oracle效能優化的學習筆記

記憶體優化 sga包括三個部分組成。資料緩衝區 日誌緩衝區及共享池 資料緩衝區 大小由db cache size引數決定。select name,value from v parameter where name in db cache size db block size shared pool ...