Oracle的又一巨型bug
關於exist中條件為true時的執行計劃問題,同事發現的,還真沒留意到:
SQL> with tmp as(
2 select 1 a from dual union all
3 select 2 a from dual union all
4 select 3 a from dual union all
5 select 4 a from dual),
6 notext as(
7 select 2 a from dual union all
8 select 3 a from dual)
9 select * from tmp a where exists(select 1 from notext b where b.a = decode(1,1,b.a,a.a))
10 /
A
----------
1
2
3
4
1
2
3
4
8 rows selected
執行計劃(紅色部分明顯錯了):
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4 | 24 | 13 (8)| 00:00:01 |
| 1 | MERGE JOIN CARTESIAN| | 4 | 24 | 13 (8)| 00:00:01 |
|* 2 | VIEW | | 2 | 6 | 4 (0)| 00:00:01 |
| 3 | HASH UNIQUE | | 2 | | 4 (50)| 00:00:01 |
| 4 | UNION-ALL | | | | | |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 7 | BUFFER SORT | | 4 | 12 | 13 (8)| 00:00:01 |
| 8 | VIEW | | 4 | 12 | 8 (0)| 00:00:01 |
| 9 | UNION-ALL | | | | | |
| 10 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 11 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 12 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 13 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
-----------------------------------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("B"."A"="B"."A")
25 rows selected
正確的結果(加了紅色部分):
with tmp as(
select 1 a from dual union all
select 2 a from dual union all
select 3 a from dual union all
select 4 a from dual),
notext as(
select 2 a from dual union all
select 3 a from dual)
select * from tmp a where exists(select 1 from notext b where b.a = decode(1,1,b.a,a.a) and rownum <= 1e100)
執行計劃(透過rownum約束了謂詞推進,這次對了):
-------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 12 (0)| 00:00:01 |
|* 1 | FILTER | | | | | |
| 2 | VIEW | | 4 | 12 | 8 (0)| 00:00:01 |
| 3 | UNION-ALL | | | | | |
| 4 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 7 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 8 | COUNT STOPKEY | | | | | |
| 9 | VIEW | | 2 | 6 | 4 (0)| 00:00:01 |
| 10 | UNION-ALL | | | | | |
| 11 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 12 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter( EXISTS (SELECT /*+ */ 0 FROM ( (SELECT /*+ */ 2 "A"
FROM "SYS"."DUAL" "DUAL") UNION ALL (SELECT /*+ */ 3 "A" FROM
"SYS"."DUAL" "DUAL")) "B" WHERE ROWNUM<=1e100))
8 - filter(ROWNUM<=1e100)
bell6248給的另一個解決辦法:
with tmp as(
select 1 a from dual union all
select 2 a from dual union all
select 3 a from dual union all
select 4 a from dual),
notext as(
select 2 a from dual union all
select 3 a from dual)
select rownum from tmp a where exists(select 1 from notext b where b.a = decode(1,1,b.a,a.a))
需要說明的是,以證明在11g裡面該bug已經修復。10201bug太多了,什麼時候發個心把版本升了。
SQL> with tmp as(
2 select 1 a from dual union all
3 select 2 a from dual union all
4 select 3 a from dual union all
5 select 4 a from dual),
6 notext as(
7 select 2 a from dual union all
8 select 3 a from dual)
9 select * from tmp a where exists(select 1 from notext b where b.a = decode(1,1,b.a,a.a))
10 /
A
----------
1
2
3
4
1
2
3
4
8 rows selected
執行計劃(紅色部分明顯錯了):
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4 | 24 | 13 (8)| 00:00:01 |
| 1 | MERGE JOIN CARTESIAN| | 4 | 24 | 13 (8)| 00:00:01 |
|* 2 | VIEW | | 2 | 6 | 4 (0)| 00:00:01 |
| 3 | HASH UNIQUE | | 2 | | 4 (50)| 00:00:01 |
| 4 | UNION-ALL | | | | | |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 7 | BUFFER SORT | | 4 | 12 | 13 (8)| 00:00:01 |
| 8 | VIEW | | 4 | 12 | 8 (0)| 00:00:01 |
| 9 | UNION-ALL | | | | | |
| 10 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 11 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 12 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 13 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
-----------------------------------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("B"."A"="B"."A")
25 rows selected
正確的結果(加了紅色部分):
with tmp as(
select 1 a from dual union all
select 2 a from dual union all
select 3 a from dual union all
select 4 a from dual),
notext as(
select 2 a from dual union all
select 3 a from dual)
select * from tmp a where exists(select 1 from notext b where b.a = decode(1,1,b.a,a.a) and rownum <= 1e100)
執行計劃(透過rownum約束了謂詞推進,這次對了):
-------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 12 (0)| 00:00:01 |
|* 1 | FILTER | | | | | |
| 2 | VIEW | | 4 | 12 | 8 (0)| 00:00:01 |
| 3 | UNION-ALL | | | | | |
| 4 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 7 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 8 | COUNT STOPKEY | | | | | |
| 9 | VIEW | | 2 | 6 | 4 (0)| 00:00:01 |
| 10 | UNION-ALL | | | | | |
| 11 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 12 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter( EXISTS (SELECT /*+ */ 0 FROM ( (SELECT /*+ */ 2 "A"
FROM "SYS"."DUAL" "DUAL") UNION ALL (SELECT /*+ */ 3 "A" FROM
"SYS"."DUAL" "DUAL")) "B" WHERE ROWNUM<=1e100))
8 - filter(ROWNUM<=1e100)
bell6248給的另一個解決辦法:
with tmp as(
select 1 a from dual union all
select 2 a from dual union all
select 3 a from dual union all
select 4 a from dual),
notext as(
select 2 a from dual union all
select 3 a from dual)
select rownum from tmp a where exists(select 1 from notext b where b.a = decode(1,1,b.a,a.a))
需要說明的是,以證明在11g裡面該bug已經修復。10201bug太多了,什麼時候發個心把版本升了。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12932950/viewspace-718193/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle的一個bugOracle
- oracle10.1.0.4.0bugOracle
- oracle interval日期函式的bug!Oracle函式
- 從Oracle 11.2.0.4 BUG到Oracle子查詢展開分析Oracle
- Oracle DBLink bug引發的故障(Session Hang Memory leak)OracleSession
- ORACLE for aix 11.2.0.1 DATAPUMP expdp之BUG 9470768OracleAI
- Oracle:Redhat 7 + Oracle RAC 11g 安裝 bug 總結OracleRedhat
- [轉帖]深度探究Linux核心透明巨型頁Linux
- MMORPG聯動&巨型BOSS設計經驗分享
- 從《Skelittle 巨型派對》看輕度聚會遊戲的困境遊戲
- 當心ORACLE 12.2 RAC新特性引入的BUG導致ORA-4031Oracle
- 【BUG】Oracle12c tablespace io statistics missing from awr reportOracle
- Oracle 12.2 BUG :分割槽維護導致的 ORA-600 KKPOFPCD3Oracle
- OpenAI CEO表示巨型AI模型時代已經結束OpenAI模型
- Oracle JDK7 bug 發現、分析與解決實戰OracleJDK
- Oracle優化案例-Bug 32852504 - ORA-60 deadlock detected(三十六)Oracle優化
- 給找 Bug 的工具(larastan)找 BugAST
- [BUG反饋]AuthGroupModel的CheckId有BUG
- String的又一次探究
- ORACLE ORA-07445 joet_create_root_thread_group ( ) + 140與BUG:19904315Oraclethread
- Oracle 12.1.0.2 expdp匯出分割槽表資料遇到BUG慢的原因和解決方法Oracle
- [BUG反饋]AdminController類的一個小bugController
- 巨型資本集團維旺迪:我只做生意,沒有感情
- 巨型異獸、吞噬進化……廣告裡有的,這遊戲都有!遊戲
- Oracle 18c bug 執行 DBMS_PDB.CHECK_PLUG_COMPATIBILITY報錯Oracle
- ogg 真的太多bug了,不穩定,太坑Action: Contact Oracle Support.Oracle
- TypeScript:又一個終將逝去的青春TypeScript
- 又一次裸辭的心得
- 又一段征程
- uniapp的bug們APP
- 微軟修復Bug的補丁產生了新的Bug微軟
- [BUG反饋]admin的二級選單排序BUG排序
- [BUG反饋]關於設定選單的BUG
- [BUG反饋]模型中刪除欄位的BUG模型
- oracle10g expdp資料泵的bug,按schema匯出,匯入impdp時無jobOracle
- Oracle優化案例-Bug 5552515引起的buffer busy waits和表物理讀(二十四)Oracle優化AI
- 【ASK_ORACLE】Oracle 12.2 Bug導致網路卡出現故障後RAC庫未向TCP註冊本地VIP監聽OracleTCP
- 談談Bug引起的複雜性“Bug-O” — OverreactedReact
- [BUG反饋]兩個關於釋出文章的BUG