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

  • 相关阅读:
    百度统计
    类的成员函数指针和mem_fun适配器的用法
    使用RTTI为继承体系编写”==”运算符
    Linux组件封装(五)一个生产者消费者问题示例
    Linux组件封装(四)使用RAII技术实现MutexLock自动化解锁
    模板系列(一)模板的模板参数
    Linux组件封装(三)使用面向对象编程封装Thread
    Linux组件封装(二)中条件变量Condition的封装
    Linux组件封装(一)中互斥锁MutexLock的封装
    迭代器适配器(二)general inserter的实现
  • 原文地址:https://www.cnblogs.com/KT-melvin/p/6754185.html
Copyright © 2011-2022 走看看