『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

转载于:https://www.cnblogs.com/KT-melvin/p/6754185.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值