11G新特性 -- Result Cache
2015-08-24 16:54
190 查看
共享池存放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功能:
使用hint开启result cache:
可以使用dbms_result_cache包来管理result cache。
动态视图:
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.
在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.
相关文章推荐
- Linux命令返回值
- SQL-Oracle游标
- ps快速蒙版怎么用
- Opencv的Point类
- 基本数据结构:链表
- Linux下重要日志文件及查看方式
- HDU 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
- Android 打造炫目的圆形菜单 秒秒钟高仿建行圆形菜单
- 在linux下新增一块硬盘的操作。(包含大于2T的硬盘在linux下挂载操作)
- 在linux下添加永久静态路由
- C#中的delegate以及利用List<T>中delegate快速实现排序、查找
- Android记录11-控制ExpandableListView展开和关闭
- Android模仿华为长按功能键实现清除内存功能
- Java提高 - 字符串循环移位
- 实例变量的初始化时机
- 生成SDK时将H、dll、lib文件输出到指定文件夹下
- 快学Scala习题解答—第十五章 注解
- Wireshark 数据分析(一)
- 关于Shader wants normals, but the mesh New Game Object doesn't have them的问题
- getAffineTransform函数