cursor_sharing=similar深度剖析
在metalink ID 1169017.1文件中,提到建議客戶不設定cursor_sharing=
similar,因為存在許多效能問題,該引數將在12g中廢除該引數,具體給出的理由
如下:
1、對於語句中包含的範圍查詢(如between,
計不適合使用;
2、影響11g Adaptive Cursor sharing特性和CBO優化器
3、Similar可能產生的一個父遊標, 多個子遊標,其效能比多個父遊標情況更加糟
糕(EXACT或 FORCE);
基於以上描述,在10g/11g進行以下的測試:
1、修改引數
alter session set cursor_sharing=similar;
2、建立測試表:
create table t1 as
select rownum id,
rpad('x',30) big_value
from all_objects
where rownum<=10;
3、統計分析
begin
dbms_stats.gather_table_stats(
user,
't1',
cascade=>true,
estimate_percent=>null,
method_opt=> 'for all columns size 1');
--method_opt=> 'for columns id size 10');
end;
/
3、進行等式測試
select /*+ mytest */ count(*) from t1 where id=2;
select /*+ mytest */ count(*) from t1 where id=3;
select /*+ mytest */ count(*) from t1 where id=4;
select /*+ mytest */ count(*) from t1 where id=5;
select /*+ mytest */ count(*) from t1 where id=6;
select /*+ mytest */ count(*) from t1 where id=7;
select /*+ mytest */ count(*) from t1 where id=8;
select /*+ mytest */ count(*) from t1 where id=9;
select /*+ mytest */ count(*) from t1 where id=10;
4、檢視各子游標情況
select count(hash_value) copies,
substrb(SQL_TEXT,1 ,80) SQL_TEXT
from v$sql
where substrb(sql_text,1,80) like '%mytest%'
group by substrb(sql_text,1,80)
order by copies asc;
COPIES SQL_TEXT
---------- --------------------------------------------------------------------------------
1 select /*+ mytest */ count(*) from t1 where id=:"SYS_B_0"
1 select /*+ mytest */ count(*) from t1 where id=:"SYS_B_0"
5、檢視標誌位狀態
select
hash_value, IS_OBSOLETE,
IS_BIND_SENSITIVE,
IS_SHAREABLE,
substrb(SQL_TEXT,1 ,80) SQL_TEXT
from v$sql
where substrb(sql_text,1,80) like '%mytest%';
輸出結果正常:
IS_OBSOLETE = N
IS_BIND_SENSITIVE=N
IS_SHAREABLE=Y
6、對範圍查詢測試(如between, < 等)
select /*+ mytest1 */ count(*) from t1 where id <2;
select /*+ mytest1*/ count(*) from t1 where id <3;
select /*+ mytest1*/ count(*) from t1 where id <4;
select /*+ mytest1*/ count(*) from t1 where id <5;
select /*+ mytest1*/ count(*) from t1 where id <6;
select /*+ mytest1*/ count(*) from t1 where id <7;
select /*+ mytest1*/ count(*) from t1 where id <8;
select /*+ mytest1*/ count(*) from t1 where id <9;
select /*+ mytest1*/ count(*) from t1 where id <10;
7、執行步驟4和步驟5檢測
步驟4的輸出結果:
COPIES SQL_TEXT
---------- --------------------------------------------------------------------------------
1 select /*+ mytest1 */ count(*) from t1 where id <:> 8 select /*+ mytest1*/ count(*) from t1 where id <:>
步驟5輸出結果:
IS_OBSOLETE = N
IS_BIND_SENSITIVE=Y
IS_SHAREABLE=Y
8、對t1.id進行直方圖統計分析,重新測步驟3指令碼,並檢視變化
begin
dbms_stats.gather_table_stats(
user,
't1',
cascade=>true,
estimate_percent=>null,
--method_opt=> 'for all columns size 1');
method_opt=> 'for columns id size 10');
end;
/
9、重新執行步驟3測試,輸出結果:
select /*+ mytest */ count(*) from t1 where id=2;
.....................
.....................
COPIES SQL_TEXT
---------- --------------------------------------------------------------------------------
1 select /*+ mytest */ count(*) from t1 where id=:"SYS_B_0"
8 select /*+ mytest */ count(*) from t1 where id=:"SYS_B_0"
IS_OBSOLETE = N
IS_BIND_SENSITIVE=Y
IS_SHAREABLE=Y
其結果發生了很大的變化
結論:在範圍查詢和直方圖統計中不適合設定similar,並且我們應該從現在開始忘記該引數similar設定的存在。
文件參看:metalink ID 1169017.1 “ANNOUNCEMENT: Deprecating the cursor_sharing='SIMILAR' setting
similar,因為存在許多效能問題,該引數將在12g中廢除該引數,具體給出的理由
如下:
1、對於語句中包含的範圍查詢(如between,
計不適合使用;
2、影響11g Adaptive Cursor sharing特性和CBO優化器
3、Similar可能產生的一個父遊標, 多個子遊標,其效能比多個父遊標情況更加糟
糕(EXACT或 FORCE);
基於以上描述,在10g/11g進行以下的測試:
1、修改引數
alter session set cursor_sharing=similar;
2、建立測試表:
create table t1 as
select rownum id,
rpad('x',30) big_value
from all_objects
where rownum<=10;
3、統計分析
begin
dbms_stats.gather_table_stats(
user,
't1',
cascade=>true,
estimate_percent=>null,
method_opt=> 'for all columns size 1');
--method_opt=> 'for columns id size 10');
end;
/
3、進行等式測試
select /*+ mytest */ count(*) from t1 where id=2;
select /*+ mytest */ count(*) from t1 where id=3;
select /*+ mytest */ count(*) from t1 where id=4;
select /*+ mytest */ count(*) from t1 where id=5;
select /*+ mytest */ count(*) from t1 where id=6;
select /*+ mytest */ count(*) from t1 where id=7;
select /*+ mytest */ count(*) from t1 where id=8;
select /*+ mytest */ count(*) from t1 where id=9;
select /*+ mytest */ count(*) from t1 where id=10;
4、檢視各子游標情況
select count(hash_value) copies,
substrb(SQL_TEXT,1 ,80) SQL_TEXT
from v$sql
where substrb(sql_text,1,80) like '%mytest%'
group by substrb(sql_text,1,80)
order by copies asc;
COPIES SQL_TEXT
---------- --------------------------------------------------------------------------------
1 select /*+ mytest */ count(*) from t1 where id=:"SYS_B_0"
1 select /*+ mytest */ count(*) from t1 where id=:"SYS_B_0"
5、檢視標誌位狀態
select
hash_value, IS_OBSOLETE,
IS_BIND_SENSITIVE,
IS_SHAREABLE,
substrb(SQL_TEXT,1 ,80) SQL_TEXT
from v$sql
where substrb(sql_text,1,80) like '%mytest%';
輸出結果正常:
IS_OBSOLETE = N
IS_BIND_SENSITIVE=N
IS_SHAREABLE=Y
6、對範圍查詢測試(如between, < 等)
select /*+ mytest1 */ count(*) from t1 where id <2;
select /*+ mytest1*/ count(*) from t1 where id <3;
select /*+ mytest1*/ count(*) from t1 where id <4;
select /*+ mytest1*/ count(*) from t1 where id <5;
select /*+ mytest1*/ count(*) from t1 where id <6;
select /*+ mytest1*/ count(*) from t1 where id <7;
select /*+ mytest1*/ count(*) from t1 where id <8;
select /*+ mytest1*/ count(*) from t1 where id <9;
select /*+ mytest1*/ count(*) from t1 where id <10;
7、執行步驟4和步驟5檢測
步驟4的輸出結果:
COPIES SQL_TEXT
---------- --------------------------------------------------------------------------------
1 select /*+ mytest1 */ count(*) from t1 where id <:> 8 select /*+ mytest1*/ count(*) from t1 where id <:>
步驟5輸出結果:
IS_OBSOLETE = N
IS_BIND_SENSITIVE=Y
IS_SHAREABLE=Y
8、對t1.id進行直方圖統計分析,重新測步驟3指令碼,並檢視變化
begin
dbms_stats.gather_table_stats(
user,
't1',
cascade=>true,
estimate_percent=>null,
--method_opt=> 'for all columns size 1');
method_opt=> 'for columns id size 10');
end;
/
9、重新執行步驟3測試,輸出結果:
select /*+ mytest */ count(*) from t1 where id=2;
.....................
.....................
COPIES SQL_TEXT
---------- --------------------------------------------------------------------------------
1 select /*+ mytest */ count(*) from t1 where id=:"SYS_B_0"
8 select /*+ mytest */ count(*) from t1 where id=:"SYS_B_0"
IS_OBSOLETE = N
IS_BIND_SENSITIVE=Y
IS_SHAREABLE=Y
其結果發生了很大的變化
結論:在範圍查詢和直方圖統計中不適合設定similar,並且我們應該從現在開始忘記該引數similar設定的存在。
文件參看:metalink ID 1169017.1 “ANNOUNCEMENT: Deprecating the cursor_sharing='SIMILAR' setting
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/354732/viewspace-690405/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- CURSOR_SHARING=SIMILARMILA
- 關於 cursor_sharing = similarMILA
- cursor_sharing : exact , force , similarMILA
- 關於cursor_sharing=similarMILA
- 關於cursor_sharing = similar(ZT)MILA
- ANNOUNCEMENT: Deprecating the cursor_sharing = ‘SIMILAR’MILA
- 關於cursor_sharing = similar (zt)MILA
- cursor_sharing = similar , exact 區別MILA
- cursor_sharing=similar 與 直方圖MILA直方圖
- cursor_sharing設定為similar 的弊端MILA
- Cursor_sharing=SIMILAR取值與直方圖(上)MILA直方圖
- Cursor_sharing=SIMILAR取值與直方圖(下)MILA直方圖
- oracle實驗記錄 (cursor_sharing(2)SIMILAR)OracleMILA
- 有關引數cursor_sharing=similar的測試MILA
- [20140802]cursor_sharing=similar.txtMILA
- Oracle 11g 中 cursor_sharing 設定為SIMILAR 導致的問題OracleMILA
- offsetParent、offsetLeft/offsetTop深度剖析
- 10203設定CURSOR_SHARING為SIMILAR導致物化檢視重新整理失敗MILA
- 深度剖析Reflect + 實戰案例
- spark核心原始碼深度剖析Spark原始碼
- ThreadLocal原始碼深度剖析thread原始碼
- URL Schemes深度剖析(上)Scheme
- 深度剖析WhatsApp傳奇APP
- Hadoop-Drill深度剖析Hadoop
- Tinyalsa PCM API 實現深度剖析API
- 深度剖析分散式事務效能分散式
- Kafka面試知識點深度剖析Kafka面試
- AndroidToast問題深度剖析(一)AndroidAST
- C語言深度剖析-筆記C語言筆記
- buffer busy wait 的深度剖析AI
- Spring AOP 原理原始碼深度剖析Spring原始碼
- 深度剖析Spring Cloud底層原理SpringCloud
- Flutter Dio原始碼分析(三)--深度剖析Flutter原始碼
- [Android] Toast問題深度剖析(二)AndroidAST
- [Android] Toast問題深度剖析(一)AndroidAST
- 深度剖析遊戲直播的黃金時代遊戲
- 深度剖析Saga分散式事務分散式
- DartVM GC 深度剖析|得物技術DartGC