coe_xfr_sql_profile.sql脚本绑定执行计划

***原文:https://www.modb.pro/db/570546

大家在实际数据库运维中,总会遇到这样的问题:

1、某个sql非常慢或者突然变得非常慢,查看后发现sql选择了错误的执行计划。如果这个sql是一个执行频率比较高的sql,那么大量用户的抱怨很快就来了,时间紧迫。

2、优化某sql时,比较好的解决办法是给sql加上hint,但是各种原因改不了代码

 

这时你将如何操作?

 

通常,我们可以重新收集相关表的统计信息,使得Oracle重新选择更优的执行计划。但是这样做有风险:涉及到这个表的所有的sql语句都会重新解析,风险不可控;如果是大表,收集统计信息时间会比较长,即时打开了并行,选择了较小的采样比,时间也可能会很长。不能修改代码或者修改代码的代价比较大,情况就不好处理了。

 

那么,本文的主角sql profile就该登场了。

 

sql profile 是干啥的呢:

1、绑定或者说是稳定执行计划。

2、不修改sql的情况下按指定的执行计划运行,达到使用hint的结果

 

主要方法有两种:

1、使用SQL Tuning Advisor

2、使用脚本手工绑定 

 


 

先来说说SQL Tuning Advisor

 

这是一个Oracle提供的工具包,找到问题sql的sqlid,跑一遍这个包,然后它会提供一个优化建议,即Oracle认为更好的一个执行计划,执行建议的脚本就完成了该计划的绑定。

 

实质上,sql profile就是为某一sql语句提供除了系统统计信息、对象(表和索引等)统计信息之外的其他信息,比如运行环境、额外的更准确的统计信息,以帮助优化器为SQL语句选择更适合的执行计划。

 

操作过程如下:

 

var tuning_task varchar2(100);  

 

DECLARE  

  l_sql_id v$session.prev_sql_id%TYPE;  

  l_tuning_task VARCHAR2(30);  

BEGIN

  l_sql_id:='4zbqykx89yc8v'; --这里制定问题sql的sqlid 

  l_tuning_task := dbms_sqltune.create_tuning_task(sql_id => l_sql_id);  

  :tuning_task:=l_tuning_task;  

  dbms_sqltune.execute_tuning_task(l_tuning_task);  

  dbms_output.put_line(l_tuning_task);  

END;  

/  

 

set long 10000

SELECT dbms_sqltune.report_tuning_task(:tuning_task) FROM dual;

 

下面会显示优化建议,根据建议接受sql profile

 

execute dbms_sqltune.accept_sql_profile(task_name => 'TASK_231',task_owner => 'SYS', replace => TRUE);

 

以上,绑定工作就完成了。

 

查看新生成的sql profile:

select name,SIGNATURE,type,category,status,force_matching from dba_sql_profiles;

 

查看sql是否使用了sql profile

select * from table(dbms_xplay_display_cursor('4zbqykx89yc8v',null,'ALL'));

在输出的note部分看到如下信息,说明sql 已正确使用了sql profile

Note  

-----  

   - SQL profile "SYS_SQLPROF_014b39f084c88000" used for this statement  

 

 


 

再来说说另一种方法:手工绑定。

 

这也是执行Oracle提供的程序包,不过有一个脚本更好用coe_xfr_sql_profile.sql(附文末),本文介绍该脚本的使用。

 

该脚本使用很简单,执行的时候需要两个参数:sqlid 和该sql 的一个plan hash value。执行完毕后会生成一个sql脚本,该脚本就是绑定该sql和plan hash value对应的执行计划,直接执行脚本即可。

 

操作如下:

 

SQL> @coe_xfr_sql_profile.sql

 

Parameter 1:

SQL_ID (required)

输入 1 的值:  b4zvp712np1bp

 

PLAN_HASH_VALUE AVG_ET_SECS

--------------- -----------

     2959412835        .112

 

Parameter 2:

PLAN_HASH_VALUE (required)

 

输入 2 的值:  2959412835

 

Values passed:

~~~~~~~~~~~~~

SQL_ID         : "b4zvp712np1bp"

PLAN_HASH_VALUE: "2959412835"

 

Execute coe_xfr_sql_profile_b4zvp712np1bp_2959412835.sql on TARGET system in order to create a custom SQL Profile with plan 2959412835 linked to adjusted sql_text.

 

COE_XFR_SQL_PROFILE completed.

SQL>@coe_xfr_sql_profile_b4zvp712np1bp_2959412835.sql

 

PL/SQL 过程已成功完成。

 

所以,关键就是找到该sql 历史执行过的最优的执行计划的plan hash value就可以了。这里可以生成sql 的awr报告,查看该sql所有的执行计划:

SQL>@?/rbdms/admin/awrsqrpt

ps:选择较长的时间段。

 

那么问题来了:如果没有可选的执行计划怎么办?

 

这就考验dba的水平了。首先构造一个和问题sql等价的sql,通过使用hint等手段让构造的这个sql按照我们预想的执行计划,找到新造sql的sqlid和理想的plan hash value,生成一份绑定脚本。然后再生成一份问题sql现有执行计划的绑定脚本。使用新sql的绑定脚本中如下部分,替换掉问题sql绑定脚本相应的地方:

 

h := SYS.SQLPROF_ATTR(

q'[BEGIN_OUTLINE_DATA]',

q'[IGNORE_OPTIM_EMBEDDED_HINTS]',

q'[OPTIMIZER_FEATURES_ENABLE('10.2.0.1')]',

q'[ALL_ROWS]',

q'[OUTLINE_LEAF(@"SEL$1")]',

q'[FULL(@"SEL$1" "T1"@"SEL$1")]',

q'[INDEX(@"SEL$1" "T2"@"SEL$1" ("T2"."OBJECT_ID"))]',

q'[LEADING(@"SEL$1" "T1"@"SEL$1" "T2"@"SEL$1")]',

q'[USE_NL(@"SEL$1" "T2"@"SEL$1")]',

q'[END_OUTLINE_DATA]');

 

哈哈,实质上这就是执行计划里outline data部分了,一堆hint而已。如果经验丰富,可以直接修改该部分为我们想用的,就不用再构造新sql了。

执行修改后的绑定脚本,大功告成。

 

sql profile的查看和效果验证方法和SQL Tuning Advisor一样。

 

coe_xfr_sql_profile.sql 脚本如下:

 

--coe_xfr_sql_profile.sql

--自动生成sql的profile

--执行脚本,提供问题sql和手工优化(加hint等)后sql的sql_id和plan_id,各自会生成两个sql脚本,用后者脚本中的hint替换前者脚本中的hint,执行修改后的脚本

 

SPO coe_xfr_sql_profile.log;

SET DEF ON TERM OFF ECHO ON FEED OFF VER OFF HEA ON LIN 2000 PAGES 100 LONG 8000000 LONGC 800000 TRIMS ON TI OFF TIMI OFF SERVEROUT ON SIZE 1000000 NUMF "" SQLP SQL>;

SET SERVEROUT ON SIZE UNL;

REM

REM $Header: 215187.1 coe_xfr_sql_profile.sql 11.4.3.5 2011/08/10 carlos.sierra $

REM

REM Copyright (c) 2000-2011, Oracle Corporation. All rights reserved.

REM

REM AUTHOR

REM   carlos.sierra@oracle.com

REM

REM SCRIPT

REM   coe_xfr_sql_profile.sql

REM

REM DESCRIPTION

REM   This script generates another that contains the commands to

REM   create a manual custom SQL Profile out of a known plan from

REM   memory or AWR. The manual custom profile can be implemented

REM   into the same SOURCE system where the plan was retrieved,

REM   or into another similar TARGET system that has same schema

REM   objects referenced by the SQL that generated the known plan.

REM

REM PRE-REQUISITES

REM   1. Oracle Tuning Pack license.

REM

REM PARAMETERS

REM   1. SQL_ID (required)

REM   2. Plan Hash Value for which a manual custom SQL Profile is

REM      needed (required). A list of known plans is presented.

REM

REM EXECUTION

REM   1. Connect into SQL*Plus as SYSDBA or user with access to

REM      data dictionary.

REM   2. Execute script coe_xfr_sql_profile.sql passing SQL_ID and

REM      plan hash value (parameters can be passed inline or until

REM      requested).

REM

REM EXAMPLE

REM   # sqlplus system

REM   SQL> START coe_xfr_sql_profile.sql [SQL_ID] [PLAN_HASH_VALUE];

REM   SQL> START coe_xfr_sql_profile.sql gnjy0mn4y9pbm 2055843663;

REM   SQL> START coe_xfr_sql_profile.sql gnjy0mn4y9pbm;

REM   SQL> START coe_xfr_sql_profile.sql;

REM

REM NOTES

REM   1. For possible errors see coe_xfr_sql_profile.log

REM   2. If SQLT is installed in SOURCE, you can use instead:

REM      sqlt/utl/sqltprofile.sql

REM   3. Be aware that using DBMS_SQLTUNE requires a license for

REM      Oracle Tuning Pack.

REM

SET TERM ON ECHO OFF;

PRO

PRO Parameter 1:

PRO SQL_ID (required)

PRO

DEF sql_id = '&1';

PRO

WITH

p AS (

SELECT plan_hash_value

  FROM gv$sql_plan

 WHERE sql_id = TRIM('&&sql_id.')

   AND other_xml IS NOT NULL

 UNION

SELECT plan_hash_value

  FROM dba_hist_sql_plan

 WHERE sql_id = TRIM('&&sql_id.')

   AND other_xml IS NOT NULL ),

m AS (

SELECT plan_hash_value,

       SUM(elapsed_time)/SUM(executions) avg_et_secs

  FROM gv$sql

 WHERE sql_id = TRIM('&&sql_id.')

   AND executions > 0

 GROUP BY

       plan_hash_value ),

a AS (

SELECT plan_hash_value,

       SUM(elapsed_time_total)/SUM(executions_total) avg_et_secs

  FROM dba_hist_sqlstat

 WHERE sql_id = TRIM('&&sql_id.')

   AND executions_total > 0

 GROUP BY

       plan_hash_value )

SELECT p.plan_hash_value,

       ROUND(NVL(m.avg_et_secs, a.avg_et_secs)/1e6, 3) avg_et_secs

  FROM p, m, a

 WHERE p.plan_hash_value = m.plan_hash_value(+)

   AND p.plan_hash_value = a.plan_hash_value(+)

 ORDER BY

       avg_et_secs NULLS LAST;

PRO

PRO Parameter 2:

PRO PLAN_HASH_VALUE (required)

PRO

DEF plan_hash_value = '&2';

PRO

PRO Values passed to coe_xfr_sql_profile:

PRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PRO SQL_ID         : "&&sql_id."

PRO PLAN_HASH_VALUE: "&&plan_hash_value."

PRO

SET TERM OFF ECHO ON;

WHENEVER SQLERROR EXIT SQL.SQLCODE;

 

-- trim parameters

COL sql_id NEW_V sql_id FOR A30;

COL plan_hash_value NEW_V plan_hash_value FOR A30;

SELECT TRIM('&&sql_id.') sql_id, TRIM('&&plan_hash_value.') plan_hash_value FROM DUAL;

 

VAR sql_text CLOB;

VAR other_xml CLOB;

EXEC :sql_text := NULL;

EXEC :other_xml := NULL;

 

-- get sql_text from memory

DECLARE

  l_sql_text VARCHAR2(32767);

BEGIN -- 10g see bug 5017909

  FOR i IN (SELECT DISTINCT piece, sql_text

              FROM gv$sqltext_with_newlines

             WHERE sql_id = TRIM('&&sql_id.')

             ORDER BY 1, 2)

  LOOP

    IF :sql_text IS NULL THEN

      DBMS_LOB.CREATETEMPORARY(:sql_text, TRUE);

      DBMS_LOB.OPEN(:sql_text, DBMS_LOB.LOB_READWRITE);

    END IF;

    l_sql_text := REPLACE(i.sql_text, CHR(00), ' ');

    DBMS_LOB.WRITEAPPEND(:sql_text, LENGTH(l_sql_text), l_sql_text);

  END LOOP;

  IF :sql_text IS NOT NULL THEN

    DBMS_LOB.CLOSE(:sql_text);

  END IF;

EXCEPTION

  WHEN OTHERS THEN

    DBMS_OUTPUT.PUT_LINE('getting sql_text from memory: '||SQLERRM);

    :sql_text := NULL;

END;

/

 

-- get sql_text from awr

BEGIN

  IF :sql_text IS NULL OR NVL(DBMS_LOB.GETLENGTH(:sql_text), 0) = 0 THEN

    SELECT REPLACE(sql_text, CHR(00), ' ')

      INTO :sql_text

      FROM dba_hist_sqltext

     WHERE sql_id = TRIM('&&sql_id.')

       AND sql_text IS NOT NULL

       AND ROWNUM = 1;

  END IF;

EXCEPTION

  WHEN OTHERS THEN

    DBMS_OUTPUT.PUT_LINE('getting sql_text from awr: '||SQLERRM);

    :sql_text := NULL;

END;

/

 

SELECT :sql_text FROM DUAL;

 

-- validate sql_text

SET TERM ON;

BEGIN

  IF :sql_text IS NULL THEN

    RAISE_APPLICATION_ERROR(-20100, 'SQL_TEXT for SQL_ID &&sql_id. was not found in memory (gv$sqltext_with_newlines) or AWR (dba_hist_sqltext).');

  END IF;

END;

/

SET TERM OFF;

 

-- to avoid errors when sql_text lacks LFs and is more than 2000 bytes

BEGIN

  :sql_text := REPLACE(:sql_text, ')', ')'||CHR(10));

  :sql_text := REPLACE(:sql_text, ',', ','||CHR(10));

  -- remove consecutive LFs

  :sql_text := REPLACE(:sql_text, CHR(10)||CHR(10)||CHR(10)||CHR(10)||CHR(10), CHR(10));

  :sql_text := REPLACE(:sql_text, CHR(10)||CHR(10)||CHR(10), CHR(10));

  :sql_text := REPLACE(:sql_text, CHR(10)||CHR(10), CHR(10));

END;

/

 

SELECT :sql_text FROM DUAL;

 

-- get other_xml from memory

BEGIN

  FOR i IN (SELECT other_xml

              FROM gv$sql_plan

             WHERE sql_id = TRIM('&&sql_id.')

               AND plan_hash_value = TO_NUMBER(TRIM('&&plan_hash_value.'))

               AND other_xml IS NOT NULL

             ORDER BY

                   child_number, id)

  LOOP

    :other_xml := i.other_xml;

    EXIT; -- 1st

  END LOOP;

EXCEPTION

  WHEN OTHERS THEN

    DBMS_OUTPUT.PUT_LINE('getting other_xml from memory: '||SQLERRM);

    :other_xml := NULL;

END;

/

 

-- get other_xml from awr

BEGIN

  IF :other_xml IS NULL OR NVL(DBMS_LOB.GETLENGTH(:other_xml), 0) = 0 THEN

    FOR i IN (SELECT other_xml

                FROM dba_hist_sql_plan

               WHERE sql_id = TRIM('&&sql_id.')

                 AND plan_hash_value = TO_NUMBER(TRIM('&&plan_hash_value.'))

                 AND other_xml IS NOT NULL

               ORDER BY

                     id)

    LOOP

      :other_xml := i.other_xml;

      EXIT; -- 1st

    END LOOP;

  END IF;

EXCEPTION

  WHEN OTHERS THEN

    DBMS_OUTPUT.PUT_LINE('getting other_xml from awr: '||SQLERRM);

    :other_xml := NULL;

END;

/

 

SELECT :other_xml FROM DUAL;

 

-- validate other_xml

SET TERM ON;

BEGIN

  IF :other_xml IS NULL THEN

    RAISE_APPLICATION_ERROR(-20101, 'PLAN for SQL_ID &&sql_id. and PHV &&plan_hash_value. was not found in memory (gv$sql_plan) or AWR (dba_hist_sql_plan).');

  END IF;

END;

/

SET TERM OFF;

 

-- generates script that creates sql profile in target system:

SET ECHO OFF;

PRO coe_xfr_sql_profile_&&sql_id._&&plan_hash_value..sql.

SET FEED OFF LIN 666 TRIMS ON TI OFF TIMI OFF SERVEROUT ON SIZE 1000000 FOR WOR;

SET SERVEROUT ON SIZE UNL FOR WOR;

SPO OFF;

SPO coe_xfr_sql_profile_&&sql_id._&&plan_hash_value..sql;

DECLARE

  l_pos NUMBER;

  l_hint VARCHAR2(32767);

BEGIN

  DBMS_OUTPUT.PUT_LINE('SPO coe_xfr_sql_profile_&&sql_id._&&plan_hash_value..log;');

  DBMS_OUTPUT.PUT_LINE('SET ECHO ON TERM ON LIN 2000 TRIMS ON NUMF 99999999999999999999;');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('REM $Header: 215187.1 coe_xfr_sql_profile_&&sql_id._&&plan_hash_value..sql 11.4.3.5 '||TO_CHAR(SYSDATE, 'YYYY/MM/DD')||' carlos.sierra $');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('REM Copyright (c) 2000-2011, Oracle Corporation. All rights reserved.');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('REM AUTHOR');

  DBMS_OUTPUT.PUT_LINE('REM   carlos.sierra@oracle.com');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('REM SCRIPT');

  DBMS_OUTPUT.PUT_LINE('REM   coe_xfr_sql_profile_&&sql_id._&&plan_hash_value..sql');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('REM DESCRIPTION');

  DBMS_OUTPUT.PUT_LINE('REM   This script is generated by coe_xfr_sql_profile.sql');

  DBMS_OUTPUT.PUT_LINE('REM   It contains the SQL*Plus commands to create a custom');

  DBMS_OUTPUT.PUT_LINE('REM   SQL Profile for SQL_ID &&sql_id. based on plan hash');

  DBMS_OUTPUT.PUT_LINE('REM   value &&plan_hash_value..');

  DBMS_OUTPUT.PUT_LINE('REM   The custom SQL Profile to be created by this script');

  DBMS_OUTPUT.PUT_LINE('REM   will affect plans for SQL commands with signature');

  DBMS_OUTPUT.PUT_LINE('REM   matching the one for SQL Text below.');

  DBMS_OUTPUT.PUT_LINE('REM   Review SQL Text and adjust accordingly.');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('REM PARAMETERS');

  DBMS_OUTPUT.PUT_LINE('REM   None.');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('REM EXAMPLE');

  DBMS_OUTPUT.PUT_LINE('REM   SQL> START coe_xfr_sql_profile_&&sql_id._&&plan_hash_value..sql;');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('REM NOTES');

  DBMS_OUTPUT.PUT_LINE('REM   1. Should be run as SYSTEM or SYSDBA.');

  DBMS_OUTPUT.PUT_LINE('REM   2. User must have CREATE ANY SQL PROFILE privilege.');

  DBMS_OUTPUT.PUT_LINE('REM   3. SOURCE and TARGET systems can be the same or similar.');

  DBMS_OUTPUT.PUT_LINE('REM   4. To drop this custom SQL Profile after it has been created:');

  DBMS_OUTPUT.PUT_LINE('REM      EXEC DBMS_SQLTUNE.DROP_SQL_PROFILE(''coe_&&sql_id._&&plan_hash_value.'');');

  DBMS_OUTPUT.PUT_LINE('REM   5. Be aware that using DBMS_SQLTUNE requires a license');

  DBMS_OUTPUT.PUT_LINE('REM      for the Oracle Tuning Pack.');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('WHENEVER SQLERROR EXIT SQL.SQLCODE;');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('VAR signature NUMBER;');

  DBMS_OUTPUT.PUT_LINE('REM');

  DBMS_OUTPUT.PUT_LINE('DECLARE');

  DBMS_OUTPUT.PUT_LINE('sql_txt CLOB;');

  DBMS_OUTPUT.PUT_LINE('h       SYS.SQLPROF_ATTR;');

  DBMS_OUTPUT.PUT_LINE('BEGIN');

  DBMS_OUTPUT.PUT_LINE('sql_txt := q''[');

  WHILE NVL(LENGTH(:sql_text), 0) > 0

  LOOP

    l_pos := INSTR(:sql_text, CHR(10));

    IF l_pos > 0 THEN

      DBMS_OUTPUT.PUT_LINE(SUBSTR(:sql_text, 1, l_pos - 1));

      :sql_text := SUBSTR(:sql_text, l_pos + 1);

    ELSE

      DBMS_OUTPUT.PUT_LINE(:sql_text);

      :sql_text := NULL;

    END IF;

  END LOOP;

  DBMS_OUTPUT.PUT_LINE(']'';');

  DBMS_OUTPUT.PUT_LINE('h := SYS.SQLPROF_ATTR(');

  DBMS_OUTPUT.PUT_LINE('q''[BEGIN_OUTLINE_DATA]'',');

  FOR i IN (SELECT /*+ opt_param('parallel_execution_enabled', 'false') */

                   SUBSTR(EXTRACTVALUE(VALUE(d), '/hint'), 1, 4000) hint

              FROM TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(:other_xml), '/*/outline_data/hint'))) d)

  LOOP

    l_hint := i.hint;

    WHILE NVL(LENGTH(l_hint), 0) > 0

    LOOP

      IF LENGTH(l_hint) <= 500 THEN

        DBMS_OUTPUT.PUT_LINE('q''['||l_hint||']'',');

        l_hint := NULL;

      ELSE

        l_pos := INSTR(SUBSTR(l_hint, 1, 500), ' ', -1);

        DBMS_OUTPUT.PUT_LINE('q''['||SUBSTR(l_hint, 1, l_pos)||']'',');

        l_hint := '   '||SUBSTR(l_hint, l_pos);

      END IF;

    END LOOP;

  END LOOP;

  DBMS_OUTPUT.PUT_LINE('q''[END_OUTLINE_DATA]'');');

  DBMS_OUTPUT.PUT_LINE(':signature := DBMS_SQLTUNE.SQLTEXT_TO_SIGNATURE(sql_txt);');

  DBMS_OUTPUT.PUT_LINE('DBMS_SQLTUNE.IMPORT_SQL_PROFILE (');

  DBMS_OUTPUT.PUT_LINE('sql_text    => sql_txt,');

  DBMS_OUTPUT.PUT_LINE('profile     => h,');

  DBMS_OUTPUT.PUT_LINE('name        => ''coe_&&sql_id._&&plan_hash_value.'',');

  DBMS_OUTPUT.PUT_LINE('description => ''coe &&sql_id. &&plan_hash_value. ''||:signature||'''',');

  DBMS_OUTPUT.PUT_LINE('category    => ''DEFAULT'',');

  DBMS_OUTPUT.PUT_LINE('validate    => TRUE,');

  DBMS_OUTPUT.PUT_LINE('replace     => TRUE,');

  DBMS_OUTPUT.PUT_LINE('force_match => TRUE/* TRUE:FORCE (match even when different literals in SQL). FALSE:EXACT (similar to CURSOR_SHARING) */ );');

  DBMS_OUTPUT.PUT_LINE('END;');

  DBMS_OUTPUT.PUT_LINE('/');

  DBMS_OUTPUT.PUT_LINE('WHENEVER SQLERROR CONTINUE');

  DBMS_OUTPUT.PUT_LINE('SET ECHO OFF;');

  DBMS_OUTPUT.PUT_LINE('PRINT signature');

  DBMS_OUTPUT.PUT_LINE('PRO');

  DBMS_OUTPUT.PUT_LINE('PRO ... manual custom SQL Profile has been created');

  DBMS_OUTPUT.PUT_LINE('PRO');

  DBMS_OUTPUT.PUT_LINE('SET TERM ON ECHO OFF LIN 80 TRIMS OFF NUMF "";');

  DBMS_OUTPUT.PUT_LINE('SPO OFF;');

  DBMS_OUTPUT.PUT_LINE('PRO');

  DBMS_OUTPUT.PUT_LINE('PRO COE_XFR_SQL_PROFILE_&&sql_id._&&plan_hash_value. completed');

END;

/

SPO OFF;

SET DEF ON TERM ON ECHO OFF FEED 6 VER ON HEA ON LIN 80 PAGES 14 LONG 80 LONGC 80 TRIMS OFF TI OFF TIMI OFF SERVEROUT OFF NUMF "" SQLP SQL>;

SET SERVEROUT OFF;

PRO

PRO Execute coe_xfr_sql_profile_&&sql_id._&&plan_hash_value..sql

PRO on TARGET system in order to create a custom SQL Profile

PRO with plan &&plan_hash_value linked to adjusted sql_text.

PRO

UNDEFINE 1 2 sql_id plan_hash_value

CL COL

PRO

PRO COE_XFR_SQL_PROFILE completed.

 

 

posted @ 2023-03-24 17:27  钱若梨花落  阅读(464)  评论(0编辑  收藏  举报