oracle 如何启用函数结果缓存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2290809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 20:01:42  来源:igfitidea点击:

How to enable Function Result Cache

oraclecachingoracle11g

提问by Peter Lang

I'm trying to use Oracle's Function Result Cacheon 11.2.0, so I did the following test:

我试图在11.2.0上使用 Oracle 的函数结果缓存,所以我做了以下测试:

CREATE OR REPLACE FUNCTION get_test_value
  RETURN NUMBER
  RESULT_CACHE
AS
BEGIN
  dbms_output.put_line( 'Called' );
  RETURN 0;
END;

SELECT get_test_value FROM dual;

My example prints Calledevery time, though.
I also tried some other examples found online, but the cache is not used.

不过,我的示例Called每次都会打印。
我还尝试了一些网上找到的其他示例,但没有使用缓存。

I tried ALTER SYSTEM SET result_cache_max_size = 10485760;
Still doesn't work.

我试了ALTER SYSTEM SET result_cache_max_size = 10485760;
还是不行。

I tried ALTER SESSION SET result_cache_mode=FORCE;(which should not be necessary) - didn't help.

我试过ALTER SESSION SET result_cache_mode=FORCE;(这不应该是必要的) - 没有帮助。

SELECT dbms_result_cache.status FROM dual;always returns DISABLED.

SELECT dbms_result_cache.status FROM dual;总是返回DISABLED

What am I doing wrong?

我究竟做错了什么?

回答by APC

Which edition are you using? The Cache functionality is only available in Enterprise Edition, so if you're trying this on a Standard Edition install it wouldn't work. It's in the Licensing Guide.

你用的是哪个版本?缓存功能仅在企业版中可用,因此如果您在标准版安装上尝试此功能,它将无法正常工作。它在许可指南中

回答by ShoeLace

Im going to add this information here because i found it useful in solving my similar problem.

我将在此处添加此信息,因为我发现它对解决我的类似问题很有用。

if you are getting a status of DISABLED or BYPASS remember

如果您获得 DISABLED 或 BYPASS 状态,请记住

*The Result Cache memory area is located in the Shared Pool so, the value of result_cache_max_size is consumed from the Shared Pool size.*

*结果缓存内存区域位于共享池中,因此,result_cache_max_size 的值是从共享池大小中消耗的。*

so check the following parameters

所以检查以下参数

show parameter shared_pool_size
show parameter result_cache_max_size
show parameter result_cache_mode

you can also try

你也可以试试

BEGIN
    dbms_result_cache.ByPass(False);
END;
/