Oracle 11g 新特性 -- 自适应游标共享(Adaptive Cursor Sharing: ACS) 说明
一.自适应游标共享(Adaptive Cursor Sharing) 说明
1.1 ACS概述
• 通过自适应游标共享,可以仅针对使用绑定变量的语句智能地共享游标。
1.2 ACS体系结构
1.2.1示例
1.2.2 说明
在以后的执行时,如果因为其他原因导致cursor 不可重用,那么就会生成一个child_cursor. 这个cursor 不可重用的原因可以查看:v$sql_shared_cursor视图。
但是Oracle 10g 下还是会使用第一次的plan,即使这个plan 不是最优的。所以在Oracle 10g下,如果数据存在数据倾斜,那么最好不要使用绑定变量。
Adaptive Cursor Sharing 默认启动的。不过要注意的是,该特性只有在绑定变量的参数个数不超过14个的情况才有效。
Oracle 10g 与 11g 绑定变量(Bind Variable) 区别 说明
http://blog.csdn.net/tianlesoftware/article/details/6591222
1.3自适应游标共享视图
1.3.1 V$SQL 中已新增了两个新列
(2)IS_BIND_AWARE:指示游标是否为能标识绑定的游标,值为YES | NO。游标高速缓存中已标记为使用能识别绑定的游标共享的游标称为能标识绑定的游标。
1.3.2 V$SQL_CS_HISTOGRAM
1.3.3 V$SQL_CS_SELECTIVITY
显示为包含绑定变量且在游标共享检查中使用了其选择性的每个谓词存储在游标中的选择性立方体或范围。它包含谓词文本和选择性范围的下限值和上限值。
1.3.4 V$SQL_CS_STATISTICS
二.MOS 说明
Adaptive Cursor Sharing in 11G[ID 836256.1]
Adaptive Cursor SharingOverview [ID 740052.1]
2.1 Introduction 介绍
Note:68992.1 "PredicateSelectivity".
Note:387394.1 Query usingBind Variables is suddenly slow
Note:430208.1 Bind PeekingBy Example
--在Oracle 11g中引入了AdaptiveCursor Sharing 特性,该特性监控查询语句执行的统计信息,并尽可能的根据相同的SQL语句,不同的绑定变量值,使用不同的执行计划。
2.2 Advantages of Adaptive Cursor Sharing(ACS的优势)
Adaptive cursor sharing is asolution to give us the shareability of binds, with the plan adaptability of literals.With adaptive cursor sharing the database can adapt execution plans based onthe selectivity of values used in binds.
This is a workaround to issueswhere different sets of bind values for a given query may have differentselectivity, leading to a situation where there may be suboptimal plans fordifferent bind sets.
Previously, workaroundsemployed would either use literal values instead of binds, which could lead toexcessive hard parsing, or apply a fixed plan that would be a compromise ofperformance between different bind selectivities.
2.3 Disadvantages of Adaptive Cursor Sharing(ACS的劣势)
There is some extra overheadassociated with Adaptive Cursor Sharing in the form of :-
(1)More Hard Parses (CPU) -Extra Hard Parses will be required when a cursor becomes "Bind Aware"as we attempt to generate the better matched execution plans for the bindselectivity.
(2) More Child Cursors(SGA) - It is recommended that some consideration be taken to increase the sizeof the shared_pool on upgrade from 10g to 11g, given the extra cursors that maybe required to accommodate this feature.
(3)More Work to Match theCursor (CPU) - More Child Cursors and the requirement to match a query to thebest execution plan for its predicate selectivity.
2.4 Extended Cursor Sharing ( Bind Sensitivity)
When a query is executed withbind peeking and binds using either one of the following relational operators =< > <= >= !=, or a user defined bind operator e.g.contains(e.job,:job,1)>0, and a change in the bind variable value maylead to a different plan, the cursor will be marked as bind sensitive.
--当我们在SQL中使用<= 等操作时,在改变绑定变量就会生成一个不同的执行计划(Cursor),并将这个cursor标记为bind sensitive,Bind-Sensitive Cursor是根据绑定变量值得到的最优执行计划的一个cursor。这个就是ECS。
The "LIKE" operatoris supported from 11.2.0.2 onwards.
Apart from checking for a validoperator there are also a number of subsequent bind sensitivity checks thatneed to be performed before it can be marked as bind sensitive, if it fails anyof these the cursor will not be marked as bind sensitive and adaptive cursorsharing would not occur.
If any of the following checks fail ECS will bedisabled :
--在以下情况会禁用ECS:
(1)Extended cursor sharingis disabled
(2)The query has no binds
(3)Parallel query is used
(4)Certain parameters like("bind peeking"=false) are set
(5)You are using a /*+NO_BIND_AWARE */ hint
(6)Outlines are being used
(7)It is a recursive query
(8)The number of binds in agiven sql statement are greater than 14.
这里绑定变量个数不能超过14个,因为ACS 在绑定变量超过14个的时候会失效。
When using SQL Plan Baselines,and there is more than one plan enabled, ACS will still be enabled to usethose plans.
When all the criteria are metthe cursor is marked as bind sensitive and a "sharing context"containing information about execution statistics of the cursor is created andstored against the cursor.
Cursors that are marked asbind-sensitive can been identified by the column IS_BIND_SENSITIVE=Y in V$SQL orV$SQLAREA.
2.5 Adaptive Cursor Sharing (Bind Aware)
If there is significantvariation in the row source cardinality for executions of the same sqlstatement in consecutive executions a cursor will be marked as bind aware.
For more information about this please see :-
Note:836256.1 AdaptiveCursor Sharing in 11G
2.6 Monitoring
V$SQL can be used to see if acursor is_bind_sensitive, is_bind_aware, or is_shareable.
The bind context informationcan be viewed via V$SQL_CS_SELECTIVITY, V$SQL_CS_STATISTICS andV$SQL_CS_HISTOGRAM
V$SQL_CS_SELECTIVITY exposesthe valid selectivity ranges for a child cursor in extended cursor sharingmode. A valid range consists of a low and high value for each predicatecontaining binds. Each predicate's selectivity (with the current bind value)must fall between the corresponding low and high values in order for thechild cursor to be shared.
V$SQL_CS_STATISTICS containsthe raw execution statistics used by the monitoring component of adaptivecursor sharing. A sample of the executions is monitored.
This view exposes whichexecutions were sampled, and what the statistics were for those executions.The statistics are cumulative for each distinct set of bind values.
V$SQL_CS_HISTOGRAM summarizesthe monitoring information stored by adaptive cursor sharing. Thisinformation is used to decide whether to enable extended cursor sharing for aquery. It is stored in a histogram, whose bucket's contents are exposedby this view.
2.7 Issues with Excessive Child Cursors
There is also a possibilitythat Adaptive Cursor Sharing may compound problems in whichexcessive numbers of child cursors are generated. This may lead toperformance degradation as large numbers of child cursor can put spacepressure on the shared pool, and may also lead to an increase in mutex X waitsfor that cursor.
Things to check.
1. Ensure that cursor_sharing is not set to SIMILAR. In 11g, this setting isnot recommended and this parameter will eventually be deprecated.
Note:1169017.1:ANNOUNCEMENT:Deprecating the cursor_sharing = 'SIMILAR' setting
2. If there are high version counts check v$sql_shared_cursor. And search MyOracle Support for notes that may allude to the cause of the excessive cursors.
Note:438755.1 :Formated V$SQL_SHARED_CURSOR Report by SQLID or Hash Value
If there are still excessivechild cursors, then Oracle Support should be contacted to assist withdiagnosing the issue.
三.ACS 启用与关闭
与ACS 相关的3个参数是:
_optimizer_adaptive_cursor_sharing
_optimizer_extended_cursor_sharing
_optimizer_extended_cursor_sharing_rel
在Oracle 11gR2的参考手册里并没有搜到这个参数的解释,不过我们可以通过查看Oracle 的参数来了解这3个参数的作用。
这里我们要用到一个视图:all_parameters. 该视图的源码参考:
Oracle all_parameters 视图
http://blog.csdn.net/tianlesoftware/article/details/6641281
SQL>select * from all_parameters where name like '%_optimizer_%_cursor_sharing%';
返回结果:
我们可以在db 运行时修改这3个参数,并且能即时生效。
关闭ACS的操作如下:
SQL> alter session set"_optimizer_extended_cursor_sharing_rel"=none;
SQL> alter session set"_optimizer_extended_cursor_sharing"=none;
SQL> alter session set"_optimizer_adaptive_cursor_sharing"=false;
关于ACS的问题,itpub上的 viadeazhu 有个更深入的研究,写得非常详细,网址如下:http://space.itpub.net/15415488/viewspace-621535
关于Oracle 10g和11g中这些参数值的变化,MOS上有篇文档说明:
PARAMETERS TO CHANGE 11.2.0.1 TO 10.2.0.4 [ID1274553.1]
These are the parameters thatare changed when setting optimizer_features_enable=10.2.0.4 in 11.2.0.1database. These values represent OFE=10.2.0.4 and -- is the 11.2.0.1 value
alter session set "_optimizer_undo_cost_change"= '10.2.0.4'; -- 11.2.0.1
alter session set "_optimizer_null_aware_antijoin" = false; -- true
alter session set "_optimizer_extend_jppd_view_types" = false; --true
alter session set "_replace_virtual_columns" = false; -- true
alter session set "_first_k_rows_dynamic_proration" = false; --true
alter session set "_bloom_pruning_enabled" = false; -- true
alter session set "_optimizer_multi_level_push_pred" = false; --true
alter session set "_optimizer_group_by_placement" = false; -- true
alter session set "_optimizer_extended_cursor_sharing_rel" = none; --simple
alter session set "_optimizer_adaptive_cursor_sharing" = false; --true
alter session set "_optimizer_improve_selectivity" = false ; -- true
alter session set "_optimizer_enable_density_improvements" = false;-- true
alter session set "_optimizer_native_full_outer_join" = off; -- force
alter session set "_optimizer_enable_extended_stats" = false; -- true
alter session set "_nlj_batching_enabled" = 0; -- 1
alter session set "_optimizer_extended_stats_usage_control" = 255; --224
alter session set "_bloom_folding_enabled" = false; -- true
alter session set "_optimizer_coalesce_subqueries" = false; -- true
alter session set "_optimizer_fast_pred_transitivity" = false; -- true
alter session set "_optimizer_fast_access_pred_analysis" = false; --true
alter session set "_optimizer_unnest_disjunctive_subq" = false; --true
alter session set "_optimizer_unnest_corr_set_subq" = false; -- true
alter session set "_optimizer_distinct_agg_transform" = false; --true
alter session set "_aggregation_optimization_settings" = 32; -- 0
alter session set "_optimizer_connect_by_elim_dups" = false; -- true
alter session set "_optimizer_eliminate_filtering_join" = false; --true
alter session set "_connect_by_use_union_all" = old_plan_mode; --true
alter session set "_optimizer_join_factorization" = false; -- true
alter session set "_optimizer_use_cbqt_star_transformation" = false;-- true
alter session set "_optimizer_table_expansion" = false ; -- true
alter session set "_and_pruning_enabled" = false ; -- true
alter session set "_optimizer_distinct_placement" = false ; -- true
alter session set "_optimizer_use_feedback" = false ; -- true
alter session set "_optimizer_try_st_before_jppd" = false ; -- true
-------------------------------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
Email: tianlesoftware@gmail.com
Blog: http://blog.csdn.net/tianlesoftware
Weibo: http://weibo.com/tianlesoftware
Twitter: http://twitter.com/tianlesoftware
转载于:https://www.cnblogs.com/tianlesoftware/archive/2012/05/16/3609291.html
Oracle 11g 新特性 -- 自适应游标共享(Adaptive Cursor Sharing: ACS) 说明相关推荐
- oracle hcmc,oracle11g中SQL优化(SQL TUNING)新特性之Adaptive Cursor Sharing (ACS)
1. ACS简介 Oracle Database 11g提供了Adaptive Cursor Sharing (ACS)功能,以克服以往不该共享的游标被共享的可能性.ACS使用两个新指标:sens ...
- Oracle 11g新特性之缓存与连接池
Oracle 11g新特性之缓存与连接池 上一篇 /下一篇 2008-03-26 16:03:19 / 个人分类:Oracle 数据库 11g面向 DBA 和开发人员的重要新特性 查看( 414 ) ...
- Oracle 11g 新特性 -- Online Patching (Hot Patching 热补丁)说明
Oracle 11g 新特性 -- Online Patching (Hot Patching 热补丁)说明 一.官网说明 MOS 的文档:RDBMSOnline Patching Aka Hot P ...
- ORACLE 11g新特性中文版
Oracle 11g 新特性 摘自ITPUB的love_zz的帖子 http://www.itpub.net/712880.html Oracle 11g 现在已经开始进行beta测试,预计在2007 ...
- Oracle 11g 新特性 -- Transparent Data Encryption (透明数据加密TDE) 增强 说明
一.TransparentData Encryption (TDE:透明数据加密) 说明 Orace TDE 是Orcle 10R2中的一个新特性,其可以用来加密数据文件里的数据,保护从操作系统层面上 ...
- Oracle 11g新特性之--虚拟列(Virtual Column)
Oracle 11g新特性之--虚拟列(Virtual Column) Oracle 11G虚拟列Virtual Column介绍 在老的 Oracle 版本,当我们需要使用表达式或者一些计算公式时, ...
- Oracle 11g新特性之 - 使用RMAN复制数据库
Oracle 11g新特性之 - 使用RMAN复制数据库 Oracle 11g新特性之 - 使用RMAN复制数据库 - 1 Oracle 11g新特性之 - 使用RMAN复制数据库 - 2 Oracl ...
- Oracle 11g新特性之--只读表(read only table)
Oracle 11g新特性之--只读表(read only table) Oracle11g推出了一个新的特性,可以将table置于read only状态,处于该状态的table的不能执行 ...
- oracle+字段+virtual,Oracle 11g新特性之--虚拟列(Virtual Column)
Oracle 11g新特性之--虚拟列(Virtual Column) Oracle 11G虚拟列Virtual Column介绍 在老的 Oracle 版本,当我们需要使用表达式或者一些计算公式时, ...
最新文章
- 给UIScrollView添加category实现UIScrollView的轮播效果
- c++新特性11 (12)weak_ptr类定义
- linux怎么下载yum包,Linux下yum下载依赖包
- 面向对象程序设计课程进度条
- MVC路由学习:自定义路由参数(用户看不到参数名),重新定义路由规则
- ensp启动设备蓝屏_Windows 10系统遇到蓝屏怎么解决?
- 【翻译】.NET 5 Preview2发布
- python——time模块实现指定时间触发器
- c++运动学正反解 ros_朔州智能【机器人关节臂】哪家强
- Java IO输入输出流 字符数组流 ByteArrayOutputStream/ByteArrayInputStream
- 从零搭建个人深度学习服务器|SSH远程登录|外网访问|手动指定ip|端口转发
- 网络服务——数据链路层--三层交换机接口模式-access和trunk命令详解
- 中国传统文化的现代意义
- yarn安装JEST报错:EPERM: operation not permitted, unlink 解决方法
- jq chosen下拉列表被遮挡
- DirectX大作业——3D场景地图
- ThinkPHP开发规范 --- 摘自ThinkPHP手册
- webpack (常问高薪面试题11道)(20220401)
- 路由器桥接:老式路由器桥接隐藏网络并开启无线隐藏网络
- 编程珠玑微信公众号-算法位运算
热门文章
- python自动化测试的工具_python自动化测试(3)- 自动化框架及工具
- python菜鸟教程split_Python split()方法
- 160 - 30 cracking4all.1
- CSS中的border-radius属性
- 汇编语言-019(汇编程序与c\c++相互调用)
- php数组的下标、extract函数
- linux 编写完程序吗,linux下编写C++程序
- 1360. 日期之间隔几天 golang
- java中日期计算时间差,java中依据,两个日期,计算时间差
- 栈空间和堆空间的区别