• 『ORACLE』SPM(下)-baseline实验(11g)


    查询baseline信息:

    SQL>select sql_handle,sql_text,plan_name,origin,version,created,last_modified,last_executed,last_verified,enabled,accepted,fixed from dba_sql_plan_baselines;

    no rows selected

    SQL>alter system set optimizer_capture_sql_plan_baselines=true;(开启自动捕获)

    System altered.

    HR@PROD>create table t3 (id int);

    Table created.

    HR@PROD>insert into t3 select level from dual connect by level<=10000;

    10000 rows created.

    HR@PROD>commit;

    Commit complete.

    模拟业务,第一次查询:

    HR@PROD>select count(*) from t3 where id=1;

    COUNT(*)
    ----------
    1

    SQL>select sql_id,sql_text from v$sql where sql_text like 'select count(*) from t3 where id=1';(查询shared pool中的关于这条sql的信息)

    SQL_ID              SQL_TEXT
    ----------------- ----------------------------------------------
    82w9knc509xx4  select count(*) from t3 where id=1

    SQL>select sql_handle,sql_text,plan_name,origin,version,created,last_modified,last_executed,last_verified,enabled,accepted,fixed from dba_sql_plan_baselines;

    no rows selected

    模拟业务,第二次查询:

    HR@PROD>select count(*) from t3 where id=1;

    COUNT(*)
    ----------
    1

    SQL>select sql_id,sql_text from v$sql where sql_text like'select count(*) from t3 where id=1';(查询shared pool中的关于这条sql的信息)

    SQL_ID               SQL_TEXT
    -----------------  ------------------------------------
    82w9knc509xx4   select count(*) from t3 where id=1

    82w9knc509xx4   select count(*) from t3 where id=1

    SQL>select sql_handle,sql_text,plan_name,origin,version,created,last_modified,last_executed,last_verified,enabled,accepted,fixed from dba_sql_plan_baselines where sql_text like '%select count(*) from t3 where id=1%';(查询baseline中的信息)

    SQL_HANDLE SQL_TEXT PLAN_NAME ORIGIN VERSION CREATED LAST_MODIF
    -------------------- --------------- --------------- -------------- ---------- ---------- ----------
    LAST_EXECU LAST_VERIF ENA ACC FIX
    ---------- ---------- --- --- ---

    SQL_f83b4cd9c6676181 select count(*) SQL_PLAN_ghfucv AUTO-CAPTURE 11.2.0.4.0 23-APR-17 23-APR-17
    from t3 where 736fsc114fae16c 09.06.44.0 09.06.44.0
    id=1 00000 PM 00000 PM
    23-APR-17 YES YES NO
    09.06.44.0
    00000 PM

    HR@PROD>set autotrace traceonly(查看执行计划)

    HR@PROD>select count(*) from t3 where id=1;

    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 463314188

    ---------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    ---------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 1 | 13 | 7 (0)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | 13 | | |
    |* 2 | TABLE ACCESS FULL| T3 | 1 | 13 | 7 (0)| 00:00:01 |
    ---------------------------------------------------------------------------

    Predicate Information (identified by operation id):
    ---------------------------------------------------

    2 - filter("ID"=1)

    Note
    -----
    - dynamic sampling used for this statement (level=2)
    - SQL plan baseline "SQL_PLAN_ghfucv736fsc114fae16c" used for this statement


    Statistics
    ----------------------------------------------------------
    53 recursive calls
    0 db block gets
    82 consistent gets
    0 physical reads
    0 redo size
    526 bytes sent via SQL*Net to client
    524 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    5 sorts (memory)
    0 sorts (disk)
    1 rows processed

  • 相关阅读:
    基本类型传递值与引用类型传递值的区别
    01 基本类型的赋值与引用类型赋值的区别
    模仿51cto搜索框
    使用map将字数组里的对象重新组装
    01day 表单组件 动态绑定变量 导航组件 地图组件 view text是否可以复制 button 上下滚动组件
    POJ1321棋盘问题(暴搜)
    Codeforces Round #620 (Div. 2) C. Air Conditioner
    Codeforces Round #620 (Div. 2) B. Longest Palindrome
    Codeforces Round #620 (Div. 2) A. Two Rabbits
    Codeforces Round #619 (Div. 2) Ayoub's function
  • 原文地址:https://www.cnblogs.com/KT-melvin/p/6754185.html
Copyright © 2020-2023  润新知