第一条语句都是全表扫描,速度是最慢的,我试了第二条语句,如果两个表xh都有索引,通过执行计划看到只能使用到tb_b的索引,所以你只能根据具体数据量的大小来选择子查询的表

解决方案 »

  1.   

    select * from tb_a a,tb_b b
     where a.xh=b.xh(+)
       and b.xh is null;
      

  2.   

    select * from tb_a where not exists(select xh from tb_b where tb_b.xh=tb_a.xh)
    给xh建索引试试,应该可以
      

  3.   

    select tb_a.*,tb_b.xh newxh from
    (select tb_a.*,tb_b.* from tb_a ,tb_b  
    where tb_a.xh=tb_b.xh(+)
    )   
    where newxh is null;
      

  4.   

    用左联接是否能快些?
    select tb_a.* from tb_a left outer join tb_b on tb_a.xh=tb_b.xh where tb_b.xh is null
      

  5.   

    select * from tb_a,(select trim(xh) from tb_a minus select trim(xh) from tb_b) t where trim(tb_a.xh)=tmp.xh