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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle 9i index bug?OracleIndex
- [Oracle] exists 和 not existsOracle
- oracle中的exists 和not exists 用法詳解Oracle
- oracle中的exists和not exists和in用法詳解Oracle
- 【原始碼】Redis exists命令bug分析原始碼Redis
- oracle中的exists理解Oracle
- oracle exists and not existOracle
- oracle中關於in和exists,not in 和 not existsOracle
- oracle in與exists 的區別Oracle
- oracle 9i for linux 9.2.0.4 中開啟autotrace中的一個bug。OracleLinux
- 9i 子查詢bug?
- oracle 用EXISTS替代INOracle
- oracle 9i wrap加密,需要指定edubug=wrap_new_sqlOracle加密SQL
- Oracle 9i/10g的Bug和修復列表及升級指南Oracle
- oracle中in和exists的區別Oracle
- (轉)ORACLE 中IN和EXISTS的區別Oracle
- Oracle中exists和in的效能差異Oracle
- 9i index bug.txt 之2Index
- Python BUG FileExistsError: [Errno 17] File exists: xxxPythonError
- Oracle 9I 下的AutoTraceOracle
- [Oracle] minus 和 not exists比較Oracle
- ORACLE 中IN和EXISTS比較Oracle
- 對IN & EXISTS NOT IN & NOT EXISTS的優化優化
- EXISTS、IN、NOT EXISTS、NOT IN的區別(ZT)
- 測試一下你的Oracle有Full Outer Join的Bug麼?9i以上請進Oracle
- oracle sql_not exists與null的測試OracleSQLNull
- 測試一下你的Oracle有Full Outer Join的Bug麼?9i以上請進(2)Oracle
- (轉)ORACLE 中IN和EXISTS比較Oracle
- Oracle groupby的bugOracle
- Oracle 9i安裝Oracle
- Uninstall Oracle 9iOracle
- oracle 9i 閃回Oracle
- ORACLE 9i statspack使用Oracle
- Oracle 9I dataguard(standby)Oracle
- Oracle 9i中監視索引的使用Oracle索引
- oracle 9i for linux的安裝OracleLinux
- oracle 9i改system的密碼Oracle密碼
- SQL中IN,NOT IN,EXISTS,NOT EXISTS的用法和差別SQL