ORA-04031錯誤的解決思路

來源:互聯網
上載者:User

使用ASMM的情況下04031問題很少,但有些應用不合理也會導致記憶體耗盡.
1.沒有使用綁定變數,導致解析資源佔用太多
2.開啟過多的cursor不釋放
3.bug

第一種.
 使用綁定變數
 使用cursor_sharing參數
第二種.
 尋找哪個會話開啟的遊標比較多
 
 SQL> select sid,count(*) from v$open_cursor group by sid order by 2 desc;

 SID   COUNT(*)
----------- ----------
 148     39
 157     25
 149     22
 147     19
 161     16
 154     15
 162      7
 156      7
 152      2
 150      2
 151      1

11 rows selected.

Elapsed: 00:00:00.01
SQL> select SID,USER_NAME,sql_text from v$open_cursor where sid in (148,157);

找出開啟遊標多的SID執行的什麼SQL,再根據業務判斷代碼位置.去修改代碼

第三種
打補丁

相關文章

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.