ORACLE 9I not exists的bug
select * from v$version where rownum=1;
BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
explain plan for
select * from wxh_tbd where object_id not in (select object_id from wxh_tbd1);
select * from wxh_tbd where object_id not in (select object_id from wxh_tbd1);
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 184 | 16744 | 31 |
|* 1 | HASH JOIN ANTI | | 184 | 16744 | 31 |
| 2 | TABLE ACCESS FULL | WXH_TBD | 10970 | 921K| 15 |
| 3 | INDEX FAST FULL SCAN| T_2 | 21692 | 105K| 4 |
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 184 | 16744 | 31 |
|* 1 | HASH JOIN ANTI | | 184 | 16744 | 31 |
| 2 | TABLE ACCESS FULL | WXH_TBD | 10970 | 921K| 15 |
| 3 | INDEX FAST FULL SCAN| T_2 | 21692 | 105K| 4 |
---------------------------------------------------------------------
explain plan for
select * from wxh_tbd where not exists (select 1 from wxh_tbd1 where wxh_tbd1.object_id=wxh_tbd.object_id);
select * from wxh_tbd where not exists (select 1 from wxh_tbd1 where wxh_tbd1.object_id=wxh_tbd.object_id);
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 549 | 47214 | 564 |
|* 1 | FILTER | | | | |
| 2 | TABLE ACCESS FULL | WXH_TBD | 549 | 47214 | 15 |
|* 3 | INDEX RANGE SCAN | T_2 | 2 | 10 | 1 |
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 549 | 47214 | 564 |
|* 1 | FILTER | | | | |
| 2 | TABLE ACCESS FULL | WXH_TBD | 549 | 47214 | 15 |
|* 3 | INDEX RANGE SCAN | T_2 | 2 | 10 | 1 |
--------------------------------------------------------------------
NOT IN ORACLE做了展開解巢狀,執行計劃走了hash join anti.
但是not exists卻沒有對子查詢進行展開。走了效率比較差的filter操作。
解決辦法,增加HINT是一個比較好的途徑。
explain plan for
select * from wxh_tbd where not exists (select /*+ unnest */1 from wxh_tbd1 where wxh_tbd1.object_id=wxh_tbd.object_id);
select * from wxh_tbd where not exists (select /*+ unnest */1 from wxh_tbd1 where wxh_tbd1.object_id=wxh_tbd.object_id);
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 184 | 16744 | 31 |
|* 1 | HASH JOIN ANTI | | 184 | 16744 | 31 |
| 2 | TABLE ACCESS FULL | WXH_TBD | 10970 | 921K| 15 |
| 3 | INDEX FAST FULL SCAN| T_2 | 21692 | 105K| 4 |
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 184 | 16744 | 31 |
|* 1 | HASH JOIN ANTI | | 184 | 16744 | 31 |
| 2 | TABLE ACCESS FULL | WXH_TBD | 10970 | 921K| 15 |
| 3 | INDEX FAST FULL SCAN| T_2 | 21692 | 105K| 4 |
---------------------------------------------------------------------
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-715431/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【原始碼】Redis exists命令bug分析原始碼Redis
- Python BUG FileExistsError: [Errno 17] File exists: xxxPythonError
- Oracle中exists和in的效能差異Oracle
- oracle 9i資料庫做spaOracle資料庫
- oracle的一個bugOracle
- Installing Oracle 9i on OELRHEL 4.8 64bitOracle
- EXISTS、IN、NOT EXISTS、NOT IN(zt)
- 在oracle 9i下線上重定義表Oracle
- oracle 9i臨時表產生過多redoOracle
- oracle10.1.0.4.0bugOracle
- oracle interval日期函式的bug!Oracle函式
- Oracle 9i統計資訊備份與恢復Oracle
- [20180808]exists and not exists.txt
- In和exists使用及效能分析(二):exists的使用
- 關於Oracle 9i字符集問題的解決辦法FCOracle
- Oralce 使用SQL中的exists 和not exists 用法詳解SQL
- sql:delete if exists還是drop if exists?SQLdelete
- exists()、not exists() 、in()、not in()用法以及效率差異
- Oracle 9i升級19C 遷移關於失效索引的梳理方法Oracle索引
- In和exists使用及效能分析(三):in和exists的效能分析
- Oracle優化案例-用left join代替反連線 not in not exists(十)Oracle優化
- oracle之優化一用group by或exists優化distinctOracle優化
- [精選] SQL中的IN與NOT IN、EXISTS與NOT EXISTS的區別及效能分析SQL
- Oracle 9i升級19C 邏輯遷移詳細方法(一)Oracle
- Oracle 9i升級19C 邏輯遷移詳細方法(二)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 9i, 10g, and 11g RAC on Linux所需要的Hangcheck-Timer Module介紹OracleLinuxGC
- in、exists與索引索引
- Oracle 9i變數窺視引起執行計劃異常故障報告Oracle變數
- Oracle:Redhat 7 + Oracle RAC 11g 安裝 bug 總結OracleRedhat
- 對線面試官:SQL中的IN與NOT IN、EXISTS與NOT EXISTS的區別及效能分析面試SQL
- 【MySQL】NOT EXISTS優化的一個案例MySql優化
- 關於hibernate的 No row with the given identifier existsIDE
- SQL語句中exists和in的區別SQL
- Oracle 9i 11g歷史庫升級遷移資料至19c CDBOracle
- elasticsearch之exists查詢Elasticsearch
- 榮耀9i引數與真機圖賞 榮耀9i配置怎麼樣?