select count(distinct t.toaddress) toaddress  from mms_mt_201004 t --100W条记录where
  not exists(select * from mms_mt_201004 t2 where t2.toaddress = t.toaddress and t2.statusreport = '1000&&1')--50W条记录
and  t.toaddress not in 
(
select distinct t3.fee_phone from tb_order t3 where   t3.business_id in('20869','20870','20871','20872')  
 and t3.mobile_status = '0' ---1W条记录
   请问该怎么优化优化

解决方案 »

  1.   

    select count(distinct t.toaddress) toaddress  from mms_mt_201004 t --100W条记录where t.statusreport != '1000&&1'and  t.toaddress not in 
    (
    select  t3.fee_phone from tb_order t3 where   t3.business_id in('20869','20870','20871','20872')  
     and t3.mobile_status = '0' ---1W条记录
    )
      

  2.   

       怎么把not in给替换掉啊
      

  3.   

    not in 有意义吗?
    类似于t.statusreport != '1000&&1'
      

  4.   

    select count(distinct t.toaddress) toaddress  
    from mms_mt_201004 t
    WHERE t.statusreport <> '1000&&1'
      AND NOT EXISTS ( SELECT 1 FROM tb_order t3 
                       WHERE t3.business_id IN ('20869','20870','20871','20872')
                         AND t3.mobile_status = '0'
                         AND t3.free_phone=t.toaddress );