• 11G新特性 -- Result Cache


    共享池存放sql语句的解析和编译版本,以便数据库能快速执行频繁执行的sql语句和plsql。

    在11g中,数据库使用result cache来存放sql和plsql的执行结果。 result cache只能在数据级别进行开启。当cache的对象被修改后,数据库会自动将result cache中的结果置为无效状态。

    result cache由两部分组成:sql查询结果缓存、plsql函数结果缓存。

    result cache memory pool是SGA新的组成部分。result cache memory pool的默认大小是由参数memory_target来决定,或者由sga_target、shared_pool_size参数决定(主要看内存管理使用了哪种方式)。 result cache使用的内存来自shared pool。

    管理result cache

    三个新的参数:

    -result_cache_max_size:result cache能使用的最大内存。(一般是memory_target*0.25%;sga_target*0.5%;shared_pool*1%-result_cache_max_result
    -result_cache_expiration

    取消result cache功能:

    SQL> alter system set result_cache_max_size=0 ;

    使用hint开启result cache:

    select /*+ result_cache +*/ department_id,avg(salary) from hr.employees group by department_id;

    可以使用dbms_result_cache包来管理result cache。

    动态视图:

    v$result_cache_statistics
    v$result_cache_objects
    v$result_cache_dependency
    v$result_cache_memory

    sql查询的result cache

    需要设置参数result_cache_mode。result_cache_mode=manual,不开启sql查询结果缓存;result_cache_mode=force,开启sql查询结果缓存

    以下限制不可使用sql查询的result cache:

    -临时表 -字典表 -不确定的pl/sql函数

    -pseudo函数的currval和nextval

    -sysdate, sys_timestamp, current_date, current_timestamp, local_timestamp, userenv, sys_context和sys_quid functions

    如果想缓存用户编写的基于索引的函数结果,需要在编写函数的时候指定关键字"deterministic",表明该函数每次执行都会返回相同的结果集。

    PL/SQL函数的result cache

    原理和sql查询result cache类似。

    创建pl/sql函数的时候需要使用关键字"result_cache"。还要满足以下的限制:

    -不可以是pipeline表函数

    -不能包含out、in out参数

    -不能是匿名块,必须是命名的

    -It can’t have any in parameters belong to the LOB type, ref cursor, and collection, object, or record types.

  • 相关阅读:
    关于jstl taglib的错误 Can not find the tag library descriptor for “http://java.sun.com/jstl/core”
    Hibernate复合主键的注解
    最详细的Log4j使用教程
    Ajax 完整教程 (转)
    Servlet3.0学习总结(一)——使用注解标注Servlet
    掌握Tiles 框架 (一)---Tiles入门和Tiles 框架和体系结构
    web.xml文件的作用及基本配置
    Axis 生成客户端client stub文件
    HTML5必须知道的那些事
    XFire创建WebService实例应用
  • 原文地址:https://www.cnblogs.com/abclife/p/4755201.html
Copyright © 2020-2023  润新知