话题讨论:
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 |