話題討論:
1.ORA-4031是Oracle中最令人厭惡的報錯,它的出現有哪幾種原因?
2.一旦出現4031錯誤。也就是說共享池內存不足的情況下,我們該怎樣釋放內存呢?你有木有遇到過對應的情形呢?請回顧下當時是怎樣解決的?
3.有一句俗語叫丟車保帥。運行計划是SQL核心關鍵所在。是否意味着在釋放內存時,不應該覆蓋運行計划這部分?當運行計划部分占用內存比較多時,怎樣優化呢?
4.消耗共享池內存的主要有兩種對象,一種是SQL,而是存儲過程、函數、包等這類可運行對象。當遇到4031錯誤時,您認為須要優先釋放哪種對象
問題分析:
1、ORA-4031錯誤的原因,通常是大量的hard parse導致了shared pool中的free list中產生大量的內存小碎片,當一個須要非常大內存來進行hard parse的sql語句到來時。無法從free list中找到內存,即使進行內存的釋放。還是不能找到符合的內存塊。從而報ORA-4031錯誤。
2. ORA-4031錯誤的解決方法:
該方法治標不治本。
V$SHARED_POOL_ADVICE displays information about estimated parse time in the shared pool for different pool sizes. The sizes range from 10% of the current shared pool size or the amount of pinned library cache memory (whichever is higher) to 200% of the current shared pool size, in equal intervals. The value of the interval depends on the current size of the shared pool.
Column | Datatype | Description |
---|---|---|
SHARED_POOL_SIZE_FOR_ESTIMATE | NUMBER | Shared pool size for the estimate (in megabytes) |
SHARED_POOL_SIZE_FACTOR | NUMBER | Size factor with respect to the current shared pool size |
ESTD_LC_SIZE | NUMBER | Estimated memory in use by the library cache (in megabytes) |
ESTD_LC_MEMORY_OBJECTS | NUMBER | Estimated number of library cache memory objects in the shared pool of the specified size |
ESTD_LC_TIME_SAVED | NUMBER | Estimated elapsed parse time saved (in seconds), owing to library cache memory objects being found in a shared pool of the specified size. This is the time that would have been spent in reloading the required objects in the shared pool had they been aged out due to insufficient amount of available free memory. |
ESTD_LC_TIME_SAVED_FACTOR | NUMBER | Estimated parse time saved factor with respect to the current shared pool size |
ESTD_LC_LOAD_TIME | NUMBER | Estimated elapsed time (in seconds) for parsing in a shared pool of the specified size |
ESTD_LC_LOAD_TIME_FACTOR | NUMBER | Estimated load time factor with respect to the current shared pool size |
ESTD_LC_MEMORY_OBJECT_HITS | NUMBER | Estimated number of times a library cache memory object was found in a shared pool of the specified size |