Filter的一个测试

本文通过一个具体的SQL测试案例,分析了Filter在执行计划中的作用和影响。Filter操作出现在exists子查询中,当外部查询返回值多时,可能导致内部查询重复扫描。优化策略包括改写exists为in子查询,以减少Filter的负面影响。测试结果显示,优化后的SQL执行效率得到提升。
摘要由CSDN通过智能技术生成
 
Filter的一个测试:
创建测试表 t1 和t2. 
create table t1 as select * from dba_objects where rownum<=5000;
create table t2 as select * from dba_objects where rownum<=5000;

执行该测试SQL,这里使用了提示来收集真实的执行计划
select /*+ gather_plan_statistics */
 count(*)
  from t1
 where exists (select 1
          from t2
         where t2.owner = t1.owner
         group by t2.object_type
        having count(*) >= 10)
   and t1.object_type = 'TABLE';


set autot off;
 
select /*+ gather_plan_statistics */
 count(*)
  from t1
 where exists (select 1
          from t2
         where t2.owner = t1.owner
         group by t2.object_type
        having count(*) >= 10)
   and t1.object_type = 'TABLE';

  COUNT(*)
----------
       519

SQL> select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
---------------
SQL_ID  49t0m3dv35346, child number 0
-------------------------------------
select /*+ gather_plan_statistics */  count(*)   from t1  where exists
(
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值