【YashanDB知识库】outline固化执行计划

【问题分类】性能优化,功能使用

【关键字】outline

【问题描述】防止SQL执行计划突变,用outline固化执行计划

【问题原因分析】防止SQL执行计划突变,用outline固化执行计划

【解决/规避方法】

点击查看代码
SQL

--创建测试outline:ol_ab/ol_ba

conn sales/sales

CREATE OUTLINE ol_ab FOR CATEGORY ctgy_ab ON

SELECT /*+ leading(a,b) */ a.area_name, b.branch_name

FROM area a, branches b

WHERE a.area_no = b.area_no

AND b.branch_no LIKE '01%'

AND a.area_no LIKE '01';

 

CREATE OUTLINE ol_ba FOR CATEGORY ctgy_ab ON

SELECT a.area_name, b.branch_name

FROM area a, branches b

WHERE a.area_no = b.area_no

AND b.branch_no LIKE '01%'

AND a.area_no LIKE '01';

 

--修改基表,交换outline

conn / as sysdba

UPDATE OL$HINTS SET OL_NAME=DECODE(OL_NAME,'OL_AB','OL_BA','OL_BA','OL_AB') WHERE OL_NAME IN ('OL_AB','OL_BA');

 

--打开outline开关

ALTER SESSION SET USE_STORED_OUTLINES=ctgy_ab;

 

--验证应用SQL执行计划

conn sales/sales

explain SELECT a.area_name, b.branch_name

FROM area a, branches b

WHERE a.area_no = b.area_no

AND b.branch_no LIKE '01%'

AND a.area_no LIKE '01';
【影响范围】严重降低SQL执行效率

【修复版本】22.2

posted @ 2024-06-05 19:10  YashanDB  阅读(7)  评论(0编辑  收藏  举报