zoukankan      html  css  js  c++  java
  • 『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

  • 相关阅读:
    Android Studio生成APK自动追加版本号
    jquery.nicescroll.min.js滚动条使用方法
    Guid.NewGuid().ToString()生成唯一码js
    解决移动端H5海报滑动插件适应大部分手机问题 手机端高度自适应
    SouthidcEditor编辑器如何支持上传png图片
    谈灰色行业网站建设需要注意的事项
    33个免费的电子商务图标集
    WebKit的已实施srcset图像响应属性
    免费清新浅色图标集
    闪光的不一定是金子:设计数据的一种常见误解
  • 原文地址:https://www.cnblogs.com/KT-melvin/p/6754185.html
Copyright © 2011-2022 走看看