ITPub博客

首页 > 数据库 > Oracle > 在oracle 10g下,outline(存储大纲)与cursor_sharing参数的依赖关系

在oracle 10g下,outline(存储大纲)与cursor_sharing参数的依赖关系

原创 Oracle 作者:kaichuanle 时间:2014-04-17 14:59:32 0 删除 编辑
在oracle 10g下,outline(存储大纲)与cursor_sharing参数的依赖关系
数据库版本:
10.2.0.1.0








生成无绑定变量的outline:
create outline o1 on 
select EMPLOYEE_ID,SALARY from employees where EMPLOYEE_ID=198;


测试outline是否生效(被使用):
ALTER SESSION SET USE_STORED_OUTLINES =true;
select name,sql_text,used from user_outlines;
select EMPLOYEE_ID,SALARY from employees where EMPLOYEE_ID=198;
select name,sql_text,used from user_outlines;


经测试,对于无绑定变量的outline,
只有当cursor_sharing参数被设置为exact,outline才能生效(被使用)。








生成带系统绑定变量的outline:
create outline o2 on 
select EMPLOYEE_ID,SALARY from employees where SALARY=:"SYS_B_0";


注:"SYS_B_0"为cursor_sharing参数在similar、force状态下,
系统自动生成的绑定变量。依次为:"SYS_B_0"、"SYS_B_1"等。


测试outline是否生效(被使用):
ALTER SESSION SET USE_STORED_OUTLINES =true;
select name,sql_text,used from user_outlines;
select EMPLOYEE_ID,SALARY from employees where SALARY=5000;
select name,sql_text,used from user_outlines;


经测试,对于带系统绑定变量的outline,
只有cursor_sharing参数被设置成similar或force时,outline才能生效(被使用),
exact会使此存储大纲不能生效。








生成带用户自定义绑定变量的outline:
create outline o3 on 
select EMPLOYEE_ID,SALARY from employees where EMPLOYEE_ID=:v1;


测试outline是否生效(被使用):
ALTER SESSION SET USE_STORED_OUTLINES =true;
select name,sql_text,used from user_outlines;
variable v1 number;
exec :v1:=199;
select EMPLOYEE_ID,SALARY from employees where EMPLOYEE_ID=:v1;
select name,sql_text,used from user_outlines;


经测试,对于带用户自定义绑定变量的outline,
无论cursor_sharing参数被设置为何值(exact、similar、force),outline都能生效(被使用)。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29612462/viewspace-1144077/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-04-17

  • 博文量
    8
  • 访问量
    80490