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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 深度剖析 Runtime
- offsetParent、offsetLeft/offsetTop深度剖析
- spark核心原始碼深度剖析Spark原始碼
- 深度剖析Reflect + 實戰案例
- 【Leetcode】800. Similar RGB ColorLeetCodeMILA
- 深度剖析Spring Cloud底層原理SpringCloud
- [Android] Toast問題深度剖析(二)AndroidAST
- [Android] Toast問題深度剖析(一)AndroidAST
- Spring AOP 原理原始碼深度剖析Spring原始碼
- Tinyalsa PCM API 實現深度剖析API
- 深度剖析Saga分散式事務分散式
- 深度剖析分散式事務效能分散式
- LeetCode之Leaf-Similar Trees(Kotlin)LeetCodeMILAKotlin
- [20180803]cursor_sharing = force.txt
- AtCoder Beginner Contest 282 G - Similar PermutationMILA
- 深度剖析isinstance的檢查機制
- Axios原始碼深度剖析 – AJAX新王者iOS原始碼
- 深度剖析卷積神經網路卷積神經網路
- Axios原始碼深度剖析 - AJAX新王者iOS原始碼
- DartVM GC 深度剖析|得物技術DartGC
- Flutter Dio原始碼分析(三)--深度剖析Flutter原始碼
- Kafka面試知識點深度剖析Kafka面試
- 整合原始碼深度剖析:Fescar x Spring Cloud原始碼SpringCloud
- JProfiler for Mac:深度剖析Java應用程式效能MacJava
- [20210627]cursor_sharing=force與orade by.txt
- ORACLE中Cursor_sharing引數詳解Oracle
- 深度剖析免費OA系統是如何盈利
- 學JS必看-JavaScript資料結構深度剖析JSJavaScript資料結構
- 深度剖析HBase負載均衡和效能指標負載指標
- 醫療防“統方”技術原理深度剖析
- Golang 定時器底層實現深度剖析Golang定時器
- 深度剖析遊戲直播的黃金時代遊戲
- Hadoop 3.0 新特性原理及架構深度剖析Hadoop架構
- 【C++】 59_類别範本深度剖析C++
- 東郊到家服務生態的深度剖析
- 電商商城創新商業模式深度剖析模式
- ArrayDeque(JDK雙端佇列)原始碼深度剖析JDK佇列原始碼
- 深度剖析如何才是真正免費OA系統?
- 萬字長文深度剖析 RocketMQ 設計原理MQ