【问题标题】:Error on Oracle: ORA-13767 when try to create a baselineOracle 上的错误:尝试创建基线时出现 ORA-13767
【发布时间】:2014-11-07 03:33:04
【问题描述】:

sql语句有2个计划,一个慢一个快。
通过使用哈希值,我尝试创建基线,我收到如下错误:

ERROR at line 1:
ORA-13767: End snapshot ID must be greater than begin snapshot ID.
ORA-06512: at "SYS.DBMS_SQLTUNE", line 4715
ORA-06512: at line 21

发现计划的最小和最大快照id
我想创建的基线是相同的。

在这种情况下,用我想要的计划创建基线的方法是什么?

感谢您的帮助!

【问题讨论】:

    标签: oracle baseline


    【解决方案1】:

    --为了避免:ORA-13767:结束快照 ID 必须大于开始快照 ID。 -- 如果 snap_ids 相同,则将 begin snap id 减一

    开始 -- 如果它不在 V$SQL 中,我们将不得不查询工作负载存储库 select count(*) into cnt from V$SQLSTATS where sql_id = '&&sqlid';

    如果 (cnt > 0) 那么 :task_name := dbms_sqltune.create_tuning_task(sql_id => '&&sqlid',scope => DBMS_SQLTUNE.scope_comprehensive,time_limit => 7200); 别的 选择 min(snap_id) 进入 bsnap 来自 dba_hist_sqlstat 其中 sql_id = '&&sqlid';

    select max(snap_id) into esnap
    from   dba_hist_sqlstat
    where  sql_id = '&&sqlid';
    
    -- in order to avoid an: ORA-13767: End snapshot ID must be greater than begin snapshot ID.
    -- if the snap_ids are the same, then lower the begin snap id by one
    if (:bsnap = :esnap) then
       :bsnap := :bsnap - 1;
    end if;
    
    :task_name := dbms_sqltune.create_tuning_task(begin_snap => :bsnap,
                                                  end_snap => :esnap,
                                                  time_limit => 7200,
                                                  sql_id => '&&sqlid',
                                                  scope => DBMS_SQLTUNE.scope_comprehensive);
    

    如果结束;

    dbms_sqltune.execute_tuning_task(:task_name);

    【讨论】:

      猜你喜欢
      • 2017-06-05
      • 2016-08-01
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-03
      相关资源
      最近更新 更多