ORACLE 9I not exists的bug

select * from v$version where rownum=1;
BANNER
----------------------------------------------------------------
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);
---------------------------------------------------------------------
| 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);
 
--------------------------------------------------------------------
| 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);
---------------------------------------------------------------------
| 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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22034023/viewspace-715431/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值