- 最后登录
- 2014-3-7
- 在线时间
- 9 小时
- 威望
- 0
- 金钱
- 70
- 注册时间
- 2013-1-15
- 阅读权限
- 10
- 帖子
- 13
- 精华
- 0
- 积分
- 0
- UID
- 867
|
1#
发表于 2013-1-15 14:41:11
|
查看: 3752 |
回复: 6
最近一直在研究SPM,本來是很簡單的一個試驗,可是結果總不是期望的,不知為何。
試驗環境:
Redhat 2.6.18-308.el5 64 bit
11.2.0.3.0 64 bit installed (standard edition one)
11.2.0.3.0 32 bit client installed(standard edition one)
步驟如下:
(1)
create table test_spm(seq_no number(10,0), flg number(10,0));
BEGIN
FOR i IN 1..10000 LOOP
insert into test_spm values(i,0);
commit;
END LOOP;
END;
/
(2)
BEGIN
DBMS_STATS.GATHER_TABLE_STATS(
ownname => 'TEST'
,tabname => 'TEST_SPM'
);
END;
/
(3)
alter system set OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES=TRUE;
show parameter OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES
NAME TYPE VALUE
------------------------------------ --------- --------
optimizer_capture_sql_plan_baselines boolean TRUE
show parameter OPTIMIZER_USE_SQL_PLAN_BASELINES
NAME TYPE VALUE
------------------------------------ --------- --------
optimizer_use_sql_plan_baselines boolean TRUE
(4)
set autotrace trace
select * from test_spm where seq_no = 1; <-- 第一次執行
Execution Plan
----------------------------------------------------------
Plan hash value: 1145642998
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 6 | 7 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TEST_SPM | 1 | 6 | 7 (0)| 00:00:01 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("SEQ_NO"=1)
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
23 consistent gets
0 physical reads
0 redo size
591 bytes sent via SQL*Net to client
523 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
set autotrace off
select sql_text,sql_handle from dba_sql_plan_baselines; <--no baselines captured
no rows selected
(5)
set autotrace trace
select * from test_spm where seq_no = 1; <-- 第二次執行
Execution Plan
----------------------------------------------------------
Plan hash value: 1145642998
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 6 | 7 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TEST_SPM | 1 | 6 | 7 (0)| 00:00:01 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("SEQ_NO"=1)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
23 consistent gets
0 physical reads
0 redo size
591 bytes sent via SQL*Net to client
523 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
set autotrace off
select sql_text,sql_handle from dba_sql_plan_baselines; <-- still no baselines captured
no rows selected
問題就在這里,爲什麽執行了兩次同一個SQL,dba_sql_plan_baselines里卻沒有任何數據呢??
|
|