现在有两张表大约都是1万6千条左右 2张表left join 执行后大约27秒很慢 求优化select tt.id,tt.email,tt.mobilenum from (select t.id,t.email,t.mobilenum from tmp_table t) tt left join 
(select u.id,u.email from hui_user u where u.meetid = 411) usr on tt.email = usr.email ;

解决方案 »

  1.   

    select tt.id,tt.email,tt.mobilenum from tmp_table tt where exists (select 1 from hui_user usr where usr.email=tt.email and usr.meetid=411);
      

  2.   

     我怎么感觉用不到hui_user这张表
      

  3.   

    试一下这个:
    select tt.id, tt.email, tt.mobilenum
      from tmp_table tt, hui_user u
     where tt.email = u.email(+)
       and u.meetid = 411;
      

  4.   

    用exists  要快一些
      

  5.   

    select tt.id, tt.email, tt.mobilenum
      from tmp_table tt, hui_user u
     where tt.email = u.email(+)
       and u.meetid(+) = 411;
      

  6.   

    这个可以,都用一张表的数据,完全可以exists,效率高很多~