在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都能生效(被使用)。
阅读(321) | 评论(0) | 转发(0) |